Files in UNIX are organized into containers called directories. Every user has their own personal (home) directory to store files in. What is more, you can organize your files by creating directories within your home directory and storing files in them. At any given time there is a directory, called the current directory, that your UNIX commands apply to. This is best explained with an example.
You can see what files you have in the current directory by typing ls (the equivalent of the MS-DOS command dir) at the command prompt, like this (this is just an example, your files will be different):
(firstname.lastname@example.org) ls total 6 -rw-r--r-- 1 grad 924 Aug 26 1996 lab1a.class -rw------- 1 grad 887 Aug 26 1996 lab1a.java drwx------ 2 grad 512 Aug 26 1996 source/ (email@example.com)Here we see two files, lab1a.class and lab1a.java, and a directory called source. You can tell directories from files because they end in a slash, /, and because the line in the output from ls starts with a d.
The current directory starts as your home directory. You can change the current directory by using the command cd. For example, if you wanted to see the contents of the source directory, you could make it you current directory by typing cd source. If you typed ls now, you would see a list of the contents of source. There are two special directories in every directory called . (pronounced dot) and .. (pronounced dot-dot). The first one refers to the current directory, and the second to the parent directory. So if you were in the directory source, typing cd .. would place you in your home directory. You will find some other useful commands in the table below.
|Command||What You Type||What it Does|
|cd||cd dirname||moves you into the directory dirname|
|ls||ls||lists the files in the current directory|
|cp||cp file1 file2||makes a copy of file1 and puts it in file2|
|mv||mv file1 file2||renames (MoVes) file1 to file2|
|rm||rm file1||deletes (ReMoves) file1|
|mkdir||mkdir newdir||makes a new directory called newdir|
|rmdir||rmdir dirname||deletes the directory dirname, which must be empty|
You can specify files not in your current directory by prepending the name with the directories you would have to go through to get to the file. For example, if the directory source contained the file garbage, you could delete it while in your home directory by typing rm source/garbage. Notice the forward slash character / which is used to separate directory names. (MS-DOS users: this is different from the backslash ( 2#2) used in MS-DOS.)
You can start programs from the command line by typing the program name followed by any arguments the command takes. For example, to compile the Java program lab1a.java, you would type javac lab1a.java. Here javac is the name of the program that compiles Java programs, and lab1a.java is filename of the Java program to be compiled. When the program finishes, you will see another command line. If the program is one that runs in a window, such as Netscape and nedit that you will see later in this document, you will want to end the line with an ampersand (&) character. This gives you your command line back without waiting for the program you started to end. So if you wanted to start Netscape from the command line, you would type netscape &.