Making and Removing Directories



next up previous contents index
Next: Copying and Removing Up: Your Home Directory Previous: Using Directories

Making and Removing Directories

Before you can copy or move files into a directory, that directory must exist, and this means you or some super friend has made that directory with the command:  

% mkdir dirname Make directory dirname.

And since she who giveth may also taketh,

% rmdir dirname Remove directory dirname.

These commands are fail safe; Unix won't let you remove a directory if there are any files in it, or let you make a directory with the a name which already exists.

As you can probably guess by now, the full path name may also be used to make a new directory (or remove an old one) anywhere in your workspace. So to make the directory lib, bohr could enter one of the following:

% mkdir /user/bohr/lib Make lib from anywhere.
% cp * /user/bohr/lib Copy all files to lib.
% ls /user/bohr/lib List files in directory.
file1 file2 file3
% cd Go to bohr's own home directory.
% mkdir lib Make lib from bohr's home directory.
mkdir: src: File exists mkdir returns an error message.
% rmdir /user/bohr/lib Remove lib from anywhere.
rmdir: src not empty Can only remove empty directory.



next up previous contents index
Next: Copying and Removing Up: Your Home Directory Previous: Using Directories