You will probably find that you eventually will accumulate dozens (or even hundreds!) of files. Grouping them into different directories makes them easy to keep track of. For example, a directory named Receipts might contain monthly receipt figures with files named jan, feb, and mar. You may want to create directories and add new files to them, or delete existing files or directories you no longer need.
Your home directory is assigned to you when you create your Uniform Access account. Whenever you log in to your account, your session begins in your home directory. Your home directory is named with your userid name, the name you use to log in. You control your home directory--you can set permissions that determine who can read, change, and execute your files. You also determine the structure of your home directory--you can create any other directories, or files you want within your home directory.
Figure 1: A Home Directory With Files and Directories
mkdir directory
This will make a directory with the name you specify
|
To make a directory for your chemistry papers and assignments, enter:
mkdir Chemistry This makes the directory named Chemistry. If you begin your directory names with a capital letter, they are easier to distinguish from your file names. |
ls
To view the names of the files and directories in a different directory, enter:
ls directory
The ls command takes several command options that let you display additional file and directory information. The following list summarizes some of the most popular options:
ls -l Displays files in long format (see File and Directory Permissions and Access)
ls -t Displays sorted by time of last modification
ls -r Displays in reverse order
ls -F Displays contents and indicates file type
You can also use the ls command with several options at once:
ls -lFt directory
mv directory1 directory2
This changes the name of directory1 to directory2.
To delete a directory, enter:
rmdir directory
To display the name of your current directory, enter:
pwd
For a user with the userid "jjaudubon," who is working in their home directory, the pwd command display would look something like this:
/ua19/S0/jjaudubon
Figure 2: A Unix Directory Structure
Because the absolute pathname starts at the root directory, it always begins with a /. All the names in a pathname are also separated by a /. Do not be confused by the dual meaning of the / character. It is both the symbol of the root directory and a separator between names. In the Unix file system, it is possible for more than one user to have a file called jan. Two files with the same name, for example jan in Figure 2, are distinguished by their absolute pathnames:
/ua19/S1/User1/Receipts/jan
/ua19/S1/User2/Vacations/jan
Both User1 and User2 can access their files named jan from their home directories using relative pathnames:
Receipts/jan
Vacations/jan
| ~ | Your home directory | ||
| .. | Parent directory-the directory just above your current directory | ||
| . | Current directory |
|
To copy a file from your home directory to your current directory, enter:
cp ~/file . This command uses the abbreviations for your home directory (~) and your current directory (.) to copy the file you specify. |
To move to another directory, enter:
cd directory
This moves you from your current directory to the directory you specify.
To move to your home directory from anywhere in the file system, enter:
cd