Some Unix Commands

These short notes give only the most basic information on the most basic commands. For more information on any command, you can use man [command name] to get more information. Unfortunately, these manual pages are usually missing examples.
If you are using a modren window interface, there are simpler point and click versions of these commands.
Directory Listing ls [-ltaF]
ls [directory name] simple directory listing. This does not list "hidden" files; their names begin with a period.
ls -F [directory name] indicate directories and programs. [I have my own computer setup so that ls always gives ls -F.]
ls -a [directory name] list "all" files.
ls -l [directory name] "long" directory listing.
ls -t [directory name] list by last time modified
ls -lt [directory name] long list by last time modified

Example: ls -alF may give something like

-rw-r--r--   1 kazdan   faculty     2760 May  8  2000 .bashrc
drwx------   5 kazdan   faculty     1024 Oct 25  1998 Desktop/
drwxr-xr-x   7 kazdan   faculty     1024 Jul 24 15:03 html/
drwx------   2 kazdan   faculty     1024 Oct 29 21:15 Mail/
-rwxr--r--   1 kazdan   faculty    14368 Apr  2  2000 Monty_Hall.html
drwxr-xr-x   7 kazdan   faculty     1024 Jul 24 15:03 html/
-rwxr-xr-x   1 kazdan   faculty       70 Feb 17  2000 projects*
A d at the start of a line means a directory. The next 9 characters (3 groups of 3 characters) specify the permissions. The first set of 3 is for the user, the second set of 3 for one's "group" and the third set for the rest of the world.
r means read permission, w write permission, and x means can execute (for a program) or can change to the directory (for a directory). Thus, projects is a program that can be read and executed by anyone while only I can write (modify) it.
The second column indicates the number of items in a directory, while the third and fourth columns give the name of the owner of the file and the group of the file. The next column gives the size of the file in bytes. The date columns give the last date (and time) the file was modified; if the file is more than 6 months old, the year is used instead of the time. The last column gives the name of the file.

Remove Files rm [-ri]
rm [file name] remove this file.
rm -i [file name] Prompt before removing each file. This is what my personal rm gives by default.
rm -r [directory name] recursively remove this directory and all its sub directories.

Change privacy chmod
Discussion: On a computer shared by many users, and also on the Internet, one needs a way to insure privacy for your files and programs. By default on many Unix computers, your files and directories are not readable by anyone except you. However, if you want to "publish" something on the Web, you need to give others access to it.
On a Unix computer there are three categories of privacy:
yourself,  your group, ,  others (the whole world).
See the above Example for ls. Many people find it simplest to change permissions using a number code. In this code
1 = permission to execute a command [or change to a directory]
2 = permission to write (modify) a file or directory
4 = permission to read a file or directory
One adds the numbers to get multiple properties. Thus 6 = 4 + 2 means both read and write permission.
Example: chmod 644 Monty_Hall.html
is what I used to make the file Monty_Hall.html (see ls above) readable and writable (6) by me, but only read (4) permission by both the file's group and all others.
chmod 755 html
is how I made the directory html read accessible to the world but only I could write to it. Since this is a directory, chmod 644 htmlwould not work.