| The mkdir
command is used to create directories or folders. Directories can
contain other directories, which are referred to as subdirectories, and
they can contain files. This section deals with user created
directories, those created by a system administrator or a user.
Directories can be created using either an absolute or a relative
pathname. You can specify more than one directory name on the same
line to create more than one new directory.
You must have the appropriate
permissions to create a directory. (Permissions are covered later in
the course.) If you change to a directory where you do not have the
correct permissions to create a new file or directory, you will
receive an error message similar to the one below:
$ mkdir /home/Olympic
mkdir: Failed to make directory "/home/Olympic"; Permission
denied
Figure
starts with the pwd command to
verify you are in your home directory and shows several examples of
using the basic mkdir
command. Variations of the ls command are used to list the directories
created. The last example shows the use of the -p (parent) option
which can create parent directories while creating lower level
directories. You can create multiple levels of directories including
all the directories in a pathname simultaneously. If you use the -p
option and specify a directory in the pathname that does not exist, it
will be created.
| Command Format: |
| mkdir [-p]
directory_name directory_name |
 |
 |
Interactive
Media Activity
(Flash,
95 kB) |
| |
Using
mkdir
and
touch
In this media activity, you are logged in as user2 and your current working directory is: /home/user2/dir4. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and type the commands that would accomplish the requested objectives.
Note: Be sure to press enter after each one. Click on step 1 to begin.
|
|
|
|
|