Quantcast

Maximum PC

It is currently Fri Aug 29, 2014 12:20 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Diagnosing problems (Great for newbs)
PostPosted: Sat Feb 12, 2005 11:37 am 
Coppermine
Coppermine

Joined: Wed Jul 07, 2004 11:07 am
Posts: 666
Location: Woodland Hills, CA
Ok, so I get a lot of people asking me about their Linux problems. Here are some things I think people new to Linux should know.

1 - The command line is a powerful tool to help diagnose problems.

Most people switching to Linux are used to Windows and a point and click interface. While these point and click interfaces (let's call them GUI's - for Graphical User Interface) are nice and easy, they also _hide_ a lot of what is going on underneath the hood. Going to command line is like opening up your hood. The Command Line Interface (now dubbed CLI) is also referred to by many as a "shell". I forgot the history of the shell, but the dominant ones in use today with Linux are "bash" - for Bourne Again Shell (Bourne created Bourne Shell for UNIX IIRC), as well as "tcsh" - for "t C-shell". You probably have "bash". You know you are in command line mode when there is no mouse pointer and nice pretty icons.

Note: Another name for the CLI is also known as a terminal window.

2. Navigation is the key

When you have problems, you'll want to look through configuration files, error logs, and other files on your hard drive. Since I heavily promote the use of CLI, I should explain how you navigate your "folders" in CLI.

If you used Windows and clicked "My Computer", you can double click through folders that are inside other folders and so on.

THESE FOLDERS ARE REALLY CALLED DIRECTORIES.

So if you don't have a GUI, how do you navigate through these directories?

The first thing you should do is type (once you are in CLI mode):

'pwd' (no quotes)

This will return a message on what directory (or folder if you like) you are currently IN.

'cd' is a command that will "Change Directories" otherwise known as double clicking a folder under My Computer. You can get to the top most directory (also called the root directory) by typing:

'cd /' - This will bring you right to the top.

Remember, 'pwd' will tell you where you are. So let's look around the current directory that you are in. Simply type:

'ls' - this will show you the files and folders (sub directories) in the folder (directory) that you are currently in.

Now try:

'ls -l'
the '-l' (dash L) is an option to 'ls'. Now 'ls' by itself (like you did above) will just show you the filenames of the files. Performing 'ls -l' will show you the details of the files, such as when it was created, the size of the file, the _permissions_ of the file, etc.

Now let's say there is a folder that you would like to go into and look around. For example, you do an 'ls' and see a folder (subdirectory) named 'music'. You want to "descend" into the music folder (subdirectory) and look around. Simply type:

'cd music'
Once in music, you can 'pwd' to make sure you got there and then do 'ls' to look around.

Now you know how to navigate through your file system under CLI instead of GUI. It's pretty simple, and once you get used to it, you'll start find a lot of tricks (such as autocomplete) that will speed up and improve your CLI prowess. I'll let you find these tricks on your own. (A hint, try hitting your "tab" button when trying to 'cd some_long_directory_name_that_is_hard_to_type')

If you start out in a shell, then no problem, you are already in it. Some distros (like Slackware) default to a CLI, while other distros default to X (If you see nice graphics and a mouse cursor, then you are in X, if not, then you are probably in CLI).

3 - Permissions, permissions, permissions

This is why Linux is so secure compared to Windows. People
like to argue that Linux hasn't been attacked as much because it isn't as obiquitous as Windows. While some of that may be true, it is also true that the permission system under GNU/Linux _definitely_ prevents a lot of worms and viruses from causing damage or spreading.

All Linux users should know about permissions. Let's talk about it.

The best way to do it is to step through it under the command line.

So let's open up a shell (or a terminal window - same thing different name).

do this:
cd /bin

ls date

NOTE: (now 'ls date' will show you the file(s) in the current directory you are in (remember 'pwd') that match the filename "date"). The file date is actually a program that will spit out the date and time to you.

Now let's look at the details of the file called 'date'.

ls -l date

you'll get something similar to this:
-rwxr-xr-x 1 root bin 41828 2004-03-15 21:08 date

This is the crucial point of this post. With that one command (ls -l date) you can find out a LOT about what is going on.

What is -rwxr-xr-x?

Well, the first dash '-' means it is a file which you can delete _IF_ you have the correct permissions. If the first dash wasn't there and instead it was a 'd' (like drwxr-xr-x), that means it is NOT a file, but a directory instead (thus the 'd').

After the dash (or d) is where it gets interesting.
"rwxr-xr-x" should be interpreted as permissions for the OWNER of the file, the permissions of GROUPS, and permissions for the REST OF THE WORLD (some average joe).

The first three positions of the line
"rwxr-xr-x" represent permissions for the OWNER of the file (the owner is the person who created the file). In our case, the owner of the file has "rwx" permissions (the first three positions). That means the owner has 'r'ead, 'w'rite, and e'x'ecute permissions (thus rwx). The owner can read the file (open it up with an editor), write to the file (change it around and save the changes), and even execute the file (run it).

The next three positions of "rwxr-xr-x" is r-x. These three positions represent the group permissions. Don't worry about the group for now, it is important just to know what "r-x" stands for. This means that the group has 'r'ead permission, DOES NOT have 'w'rite permission (thus you see a dash '-' instead of a 'w'), but DOES have e'x'ecute permissions.

The last three positions of "rwxr-xr-x" is again r-x. These last three positions represent the permissions of this file for the REST OF THE WORLD. Thus in this case, the rest of the world can only read and execute the file.

So who is the owner of the file? Let's look again at the details of the file date.

ls -l date

-rwxr-xr-x 1 root bin 41828 2004-03-15 21:08 date

the third part of this is the owner. Here the owner of the file 'date' is named 'root'.

the fourth part of this is the name of the group. Here the group is 'bin'

Sidenote: Root is omnipotent. Root is god to your machine. Root owns your machine. Only YOU should know the password to the account called 'root'. Also, you should NEVER run around as root (while doing everyday computer tasks other than maintenance). Since root is god, root can bypass ALL permissions. THIS IS WHY WINDOWS IS INSECURE. YOU ARE ALWAYS RUNNING AROUND AS ROOT (by default) which means you can accidentally erase or alter key system files, or other programs can trick you into running them while you are ROOT. You'll want to create a separate account to do everyday tasks (surf the web, check email, download pr0n,etc.)

So let's put it all together:
by doing 'ls -l date' you get
-rwxr-xr-x 1 root bin 41828 2004-03-15 21:08 date

from that you can tell that 'root' owns the file called "date". You can also tell that root has read/write/execute permissions, that the group 'bin' has read and execute permission, and then EVERYONE ELSE has read/execute permission.

Another example to solidfy:
-rwxr-x--- 1 ken users 1234 2005-02-12 14:32 some_exampel_file

the file name is "some_exampel_file" [sic].
'ken' is the owner of this file (he probably created it)
'ken' can read it, write to it, and execute it
other accounts that are in the group called 'users' can read it, and execute it.
the REST OF THE WORLD can do NOTHING with it (notice the last three positions of "rwxr-w---" is all dashes "---", thus accounts that are not 'ken' and accounts not in the group 'users' can do NOTHING with this file.

This should be enough for you to get by. When you have problems, and other forum users ask to see what permissions are on that file...refer to the above.

I'm sure I missed a lot of stuff, please add on if you think I missed out on something very 'key'.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Feb 13, 2005 3:44 pm 
8086
8086

Joined: Fri Feb 11, 2005 1:29 am
Posts: 96
you should also mention that you can add users through the command line through the the useradd command

i forget the modifiers to make wheel and give accesses so that you may give each user a unique ability.. if someone could add on the rest?


Top
  Profile  
 
 Post subject:
PostPosted: Sun Feb 13, 2005 6:51 pm 
Million Club - 5 Plus*
Million Club - 5 Plus*
User avatar

Joined: Sun Sep 12, 2004 6:37 pm
Posts: 4745
Location: In the monkey's litterbox
cd ~ takes you to your home directory


Top
  Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 1:10 pm 
Little Foot
Little Foot
User avatar

Joined: Tue Feb 01, 2005 7:20 am
Posts: 168
cbvtank wrote:
i forget the modifiers to make wheel and give accesses so that you may give each user a unique ability.. if someone could add on the rest?


you mean the "sudo" command? that will let you "visudo" the config file where you can assign specific root-level tasks. we use it a lot for application administrators who don't have root access, very convenient.

Also distribution-specific package mangement tools for installing software and updating / patching:

Mandrake's urpmi
http://qa.mandrakesoft.com/twiki/bin/vi ... iResources

Debian's apt
http://www.debian.org/doc/manuals/apt-h ... ex.en.html

and RedHat / Fedora's up2date utility

(I think it's a PITA, it uses yum in the background just use it instead)

rpm --import /usr/share/rhn/RPM-GPG-KEY
rpm --import /usr/share/rhn/RPM-GPG-KEY-fedora
yum -y update

http://www.fedorafaq.org/#getsoftware


Top
  Profile  
 
 Post subject:
PostPosted: Sat Feb 19, 2005 7:23 am 
I'd rather be modding!
I'd rather be modding!
User avatar

Joined: Fri Jun 25, 2004 3:47 pm
Posts: 3731
Location: Las Vegas
smartcat99s wrote:
cd ~ takes you to your home directory


cd .. backs you out one directory.

Not a bad newbie post - maybe a refined version could go in the FAQ?

Manta


Top
  Profile  
 
 Post subject:
PostPosted: Sat Feb 19, 2005 12:51 pm 
Coppermine
Coppermine

Joined: Wed Jul 07, 2004 11:07 am
Posts: 666
Location: Woodland Hills, CA
I forgot to mention that you should hit 'return' or 'enter' after each command.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Feb 20, 2005 11:02 pm 
8086
8086

Joined: Sun Feb 20, 2005 7:48 pm
Posts: 8
smartcat99s wrote:
cd ~ takes you to your home directory


just "cd" will do

but let's say you are root and want to copy a file to a user directory:

cp this_file.txt ~user/public_html && chown user:group ~user/public_html/this_file.txt


and to add my tid bit:


fastduke@pythwont:~ $ history |grep ssh 460 ssh lugicc@lugicc.org
462 ssh fastduke@domain.net
463 ssh fastduke@domain.net
467 ssh fastduke@domain.net
fastduke@pythwont:~ $ !462

that !462 will execute the command "ssh fastduke@domain.net"


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group