University of Wyoming
Division of Information Technology
Ask IT Help Documents
![]() |
General |
A directory is a collection of files and information about those files. The information about a file includes its name as well as various attributes of the file, such as permissions and size. By default, at login you are placed in what is termed your home directory, the top-most level directory of your username. In a listing of files in one's directory, a subdirectory is flagged with a slash (/ ) after its name.
Below are the UNIX commands necessary to create, delete, and change directories in your account. Remember, UNIX is case sensitive. For more complete information consult the UNIX man pages for each particular command.
The UNIX file structure is all based on the system root directory (referred to as /). From there, subdirectories comprise the rest of the system.

Note: This is an example and does not comprise the whole file structure.
There are two ways to reference a file or directory in UNIX. One way is called an Absolute Path. That is a reference to a file from the system root directory. An example would be /ftp/etc/motd. This is the Absolute Path name for the FTP Message Of The Day file. You can use this reference no matter where you are in the file structure. Absolute Paths always begin with a slash (/).
The second way to reference files is called the Relative Path name. The relative path name is a reference to a file or directory based on where you are in the file system. If, for instance, you are in the /home/cowboyjoe directory and want to read a file in the /home/cowboyjane directory called data.txt using the more command you could type more ../cowboyjane/data.txt.
In this illustration, the directories cowboyjoe and cowboyjane are subdirectories, or child directories of the directory home.
List the contents of a directory by entering ls as in the example:
frontier:˜>ls
Note: Files with a slash (/) after their names are subdirectories. Files with an at sign (@) after their names are links to a file or a directory in another directory. Files with an asterisk (*) after their names are executables.
To create a subdirectory, enter mkdir Directory_name
For example, let us say our directory name is MYDIR.
frontier:˜>mkdir mydir
A subdirectory named mydir is created in the current directory.
To move down to a subdirectory, enter cd Directory_name
For example, to move down more than one level at a time the directory names may be put one after the other separated by slashes
frontier:˜> cd Directory_name1/Directory_name2
To move up a directory level, enter cd ..
frontier:˜> cd ../Directory_name
This command will move up one directory and down another.
To copy a file, enter cp source_pathname target_pathname
To copy a file called data.txt to backup.txt one would type:
frontier:˜> cp data.txt backup.txt
To move a file, enter mv filename
To move a file called data.txt to a subdirectory called datafiles one would type:
frontier:˜> mv data.txt datafiles
Note: If a subdirectory named datafiles does not exist as a child of the current directory, the file data.txt will be RENAMED to a file called datafiles.
To delete a file, enter rm filename
To delete a file called data.txt, one would type:
frontier:˜> rm data.txt
To delete a directory, enter rmdir directory_name
To delete a directory, ensure you're in the parent directory and type:
frontier:˜> rmdir directory_name
Note: If the directory is not empty, this command will fail. If you use the flag -r you can recursively delete all subdirectories beneath the directory listed as directory_name.
An example of this type of deletion is:
frontier:˜> rmdir -r directory_name
Note: Be very careful you know exactly what you are doing if you type this command!
Reviewed: 0706 By: CD
Additional help with the installation and configuration of
UW-supported software is available:
Faculty/Staff
Contact your IT user consultant
(www.uwyo.edu/infotech/services/helpdesk/uc/)
Contact the IT Help Desk at 766-HELP (4357), option 1
Email UserHelp@uwyo.edu
Students
Email ASU-IT@uwyo.edu
Contact the IT Help Desk at 766-HELP (4357), option 1
Come to the student computer lab in the lobby of the
Information Technology Center.