Information Technology Reference
In-Depth Information
Directories
Several commands are used to create, move, and delete directories.
These are:
mkdir(1) —Creates a directory
mv(1) —Moves a file or directory
rmdir(1) —Removes a directory
The following sections discuss each of these commands.
Creating Directories Using the mkdir Command
The mkdir(1) command is used to create the directory specified as a
command-line argument. The command-line argument can be an absolute
pathname (from / ) or a pathname relative from the current directory. The
directory will be owned by the user account used to create the directory and
the owner's primary group. It will be created with access permissions based
on the current umask or the access permissions specified by the -m mode com-
mand-line argument where mode is a set of permissions defined using
absolute mode format. Multiple directories can be created by specifying
them as command-line arguments (separated by spaces).
Normally the directory in which the new directory is to be created must
already exist. However if the -p command-line argument is specified, any
necessary parent directories are created first. The following listing shows
several uses of the mkdir command. The first creates a directory using the
umask permissions. The second creates a directory with specified permis-
sions. The third fails because a necessary parent directory does not exist.
However, the fourth mkdir command uses the -p command-line argument to
create it.
# mkdir exam
# ls -l exam
total 0
# ls -ld exam
drwxr-xr-x 2 root other 512 Apr 13 17:32 exam
# mkdir -m 777 test2
# ls -ld test*
drwxr-xr-x 2 root other 512 Apr 13 17:32 exam
drwxrwxrwx 2 root other 512 Apr 13 17:33 test2
Search WWH ::




Custom Search