Lesson 2: Working with Directories in Unix
Making Directories:
To make a directory we type the command mkdir followed by the directory name.
Example
% mkdir training – This will create a directory called triaining in you current working directory.
Changing Directory:
To change directory in Unix we use the command cd followed by the directory name.
Example:
cd /usr – changes you from the current working directory to the usr directory.
You can now type ls to view the contents of the /usr directory.
To move back a direct we use the command
% cd ../ - this moves your current working directory back one directory.
Example:
Our current working directory /usr/test and now we enter cd ../. Our current working directory becomes /usr again.
Current Working Directory:
In unix to find the current working directory we use a command called pwd. PWD becomes more important as you become more experienced as it enables you to work out where you are in relation to the whole file-system
Example:
% pwd – would return /usr/test if we where in the direct /usr/test
Removing Directories;
Unix allows to create directories easily with mkdir we can also remove directories just as easily with rm. You need to be very careful when using the command rm as it removes your directory permanently.
So lets look at the command
% rm training - removes the directory called training from the filesystem.
% rm –R training – removes the directory training and all subdirectories with out prompting you.