Create a new directory in Unix
To create a subdirectory in the home directory of your Unix
account, use the mkdir
command. For example, to create a
subdirectory called work
, at the Unix prompt from within
your home directory, enter:
mkdir work
The mkdir
command requires at least one argument and will take
multiple arguments. To create three directories named
work
, programs
, and reports
,
enter:
mkdir work programs reports
If you're currently in your home directory and you want to make a new
directory in another directory, you don't need to use the cd
command first. You may specify a pathname with the mkdir
command, for example:
mkdir bin/work
The mkdir
command in conjunction with the
-p
option creates the directories specified in a
path. This is very useful when you want to make a directory structure that
is several directories deep, and none of the subdirectories exist yet. For
example, the following command will create the work
,
work/programs
, work/programs/reports
, and
work/programs/reports/completed
subdirectories:
mkdir -p work/programs/reports/completed
Without the -p
option, this command would have
returned an error.
For more information on the mkdir
command, see the online
manual. At the Unix shell prompt, enter:
man mkdir
At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.
This is document abng in the Knowledge Base.
Last modified on 2023-07-14 08:28:43.