1. The Basics

These are the commands which you have to know in order to be basically functional with a shell (command line).

ls

List directory contents.

ls -l long listing with dates and permissions

ls -a list all, including hidden files (hidden files start with a period)

cd

Change directory.

cd - change to previous directory

cd ~ change to home directory

cd .. change to parent directory

pwd

Print current (working) directory.

cp

Copy file(s).

cp -r somedir somedest Copy recursively (directory and all contents)

mv

Move (or rename) a file (or directory)

rm

Delete (remove) a file.

rm -r somedir Delete recursively (directory and all contents)

rm -ri somedir Delete recursively, but prompt before each removal

rm -rf somedir Delete recursively, never prompt

mkdir

Create directory.

rmdir

Remove (empty) directory.

cat

Print file contents (to console).

less

Scroll through file contents, one page at a time.

SPACEBAR to advance a page, B to go back a page, Q to quit, /pattern to search for pattern

exit

Close shell. If this is your login shell, you will log out.

To get detailed help on a particular command or program, you can try the following.

Tip

You can read man and info pages with Konqueror (the KDE web browser) or Galeon, which is nice because then they are nicely formatted and have links and such like. For example, to read the man page on the tar command, enter man:/tar in the address bar; to read the info page on tar enter info:/tar. To get the list of info topics, just enter info:/.

Since Linux is a multi-user system, file permissions are important. In Linux, there are separate read, write and execute permissions for the owner of the file ("user"), the "group", and everyone else ("other"). You can find out what permissions a file has with ls -l . Here's an example:
-rw-rw-r--    1 nodwell  mbelab      45570 Jul  9 13:10 kate.png
The series of 9 characters at the beginning of the line spcifies the permissions in order of owner, group, other. In this case, there are read and write permissions for owner and group, and only read permissions for other. You can also see that the owner is "nodwell", and the group is "mbelab".

As an example of changing permissions, let's assume I have a file called foo which I want others in the "mbelab" group to be able to read and write. To do this I change the group to mbelab and set the group read and write permissions:

chgrp mbelab foo

chmod g+rw foo

I should also make sure that the directory that this is in, and all the higher (lower?) directories are actually readable by the group. For example:

chmod g+rx /home/nodwell/shared_stuff

chmod g+rx /home/nodwell

Notice that I also set the executable bit for the directories, which allows someone in the group to actually switch into that directory. (Not very logical I admit):

To change the group and permissions on a directory and everything in it, including subdirectories and their contents, use the -R (recursive) flag:

chgrp -R mbelab /home/nodwell/shared_stuff

chmod -R g+rw /home/nodwell/shared_stuff

Now suppose that we want all files which are created in /home/nodwell/shared_stuff to automatically have the group mbelab. Assuming you've already changed the group of this directory to mbelab, you can do this by setting the group sticky bit:

chmod g+s /home/nodwell/shared_stuff