( Working with Directories)
1. pwd (Print Working Directory)
- The basic tool to move around files and directories is the command
pwd, which prints the name of the directory you are working in.
This says that you are working in the directory cs240B, in the directory usr, which in turn is in the home directory.
2.Making a directory
It's always convinient to arrange all the files related to the same project in one directory. You can create a new directory by using the command
mkdirfollowed by the name of the directory you want to create at the prompt. It is also easier compile all the files using Makefile if they are in the same directory.
e.g.: To make a directory "cs561" type
<machine>% mkdir cs561
3.Removing a directory
To remove a directory type
rmfollowed by the name of the directory. You can remove a directory if and only if it is empty. If the directory has any contents UNIX will not allow you to remove the directory, you will have to delete all the contents of the directory and then erase it.
e.g.:- to remove the directory cs506 type
<machine>% rmdir cs506
4.Changing the Directories :
1. To change from one directory to another:
- we use the command
cdwhich stands for change directory.Type cd followed by the directory name if it is in the working directory or by including the full path of the directory you want to change to.
EXAMPLE: if you want to enter the directory cs240B type
if the directory is in the current directory then you don’t have to type the whole path just the directory name.
2. To go to the previous (next level up) directory
- use the command
If the current working directory is :
EXAMPLE: If we want to go the level above the current directory. At the prompt type
<machine>% cd ..
The Current working directory now is :
In the above command
..refers to the directory one level closer to the root or to theparent of the working directory. The
.signifies the current directory.
3. Returning to the home directory
cdcommand will take you to the directory where you log in
4. Go directly to the root directory.
<machine>% cd /takes you directly to the root directory.
PREVIOUS HOME NEXT