Linux/Unix – Making directories

Making a Directory

 Use mkdir (“make directory”) to make a new directory, giving the path name of the new directory as an argument. Directory names follow the same conventions as used with other files−−that is, no spaces, slashes, or other unusual characters are recommended.

To make a new directory called `work’ in the current working directory, type:

$ mkdir work


To make a new directory called `work’ in the `/tmp’ directory, type:

$ mkdir /tmp/work


Making a Directory Tree

 Use mkdir with the `−p’ option to make a subdirectory and any of its parents that do not already exist. This is useful when you want to make a fairly complex directory tree from scratch, and don’t want to have to make each directory individually.

To make the `work/completed/2008′ directory−−a subdirectory of the `completed’ directory, which in turn is a subdirectory of the `work’ directory in the current directory, type:

 $ mkdir −p work/completed/2008

This makes a `2008′ subdirectory in the directory called `completed’, which in turn is in a directory called `work’ in the current directory; if the `completed’ or the `work’ directories do not already exist, they are made as well (if you know that `work’ and `completed’ both exist, the above command works fine without the `−p’ option).


About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on March 16, 2009, in Unix/Linux. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: