A free Basic UNIX-training with muLinux
Making and Deleting Directories
Many files are created while working at the computer,
these can be letters, graphics, spreadsheets, etc.
To keep control it's best to put these files in directories.
For example, a directory can be named "Office" .
This directory can have subdirectories, like "letters",
"invoices", "statements" etc.
As a normal user we have a home directory with our login name in the
/home directory and we must put our directories and files in this directory.
For example, if your login-name is
"Robert" .
Then our home directory would be:
/home/Robert.
It is common practice to use your name.
So you might create the directory structure:
/home/Robert/Office
/home/Robert/Office/letters
/home/Robert/Office/invoices
/home/Robert/Office/statements
Here the graphical version (in german):
Make directories with mkdir
Directories are created with the command mkdir
(make directory).
We give the name of the directory we want to createas a parameter .
/# cd /home
/home# mkdir
Robert Use
your own name.
/home# cd Robert
/home/Robert# mkdir
Office
/home/Robert# cd
Office
/home/Robert/Office# mkdir
letters
/home/Robert/Office# mkdir
invoices
/home/Robert/Office# mkdir
statements
/home/Robert/Office# ls
letters/ statements/
invoices/
/home/Robert/Office#
First we change to our /home directory and create our
directory Robert.
Then we change to our home directory Robert and create the directory
Office.
In this directory we create the three subdirectories, letters, invoices, statements.
These are listed with the command ls.
Remove a Directory with the Command rmdir or rm
-r
Empty directories are removed with the command rmdir
(remove directory).
/home/Robert/Office/# rmdir
statements
Directories containing files can be removed with the command rm -r.
The option -r means recursively.
/home/Robert/Office/# cd
..
/home/Robert/# rm -r
Office
The directory Office is removed with all the subdirectories.
Be aware that this command removes all the underlying directories and
files.
|
Warning: When the command
rm -r / is used by the superuser, all directories on all the
harddisk are removed.
This command is much more efficient than the format command in DOS.
Format just deletes a harddisk.
rm -r / removes all directories in the main directory.
/.
But because more devices (also from other machines on the network) are
mounted in directories, this action would be fatal.
|
Help Commands
Many commands have various options, which are difficult to remember.
The option --help with most commands in muLinux, lists these
options.
The next example will list the options for the command rm.
Please don't forget the space after rm.
/# rm --help
Exercise
Create the following directory structure.
Write down the commands and work them up on paper.
Then enter and list them.
/home/robert/exercise
/home/robert/exercise/dir1
/home/robert/exercise/dir1/dir11
/home/robert/exercise/dir1/dir12
/home/robert/exercise/dir2
/home/robert/exercise/dir2/dir21
/home/robert/exercise/dir2/dir22
Here listed graphically (german):
|