theshell.ch/site/pages/fs/mkdir.html
bevilj af40908294 order pages for navigation
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@254 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-18 20:38:56 +00:00

59 lines
1.5 KiB
HTML

---
layout: page
category-page: fs
category-title: FileSystem
tags: working directory current position where
author: Mirko Ponzio
title: mkdir
previous-page: pages/fs/ls.html
next-page: pages/fs/mv.html
---
<!-- Co-authored with Alessandro Marinelli -->
The <code>mkdir</code> command is used to create new directories<br>
The name stands for <i>MaKe DIRectory</i>.<br>
The default ls command syntax is:
<pre>
mkdir [flags] [-m mode] directory_name ...
</pre>
Where [flags] are the mkdir <code>-p</code> and <code>-v</code> - flags,
read below for more info, and <i>directory_name</i> is the
name of the new directory we are going to create.<br><br>
<h3>Create a new directory</h3>
Let's see how to create a new directory:
<pre>
ls
mkdir test_directory
ls
test_directory
</pre>
<h3>Create a path of directories</h3>
Using the flag <code>-p</code> we can create a path of directories, allowing us
to build more than a directory at once.
<pre>
mkdir -p test_directory/subdir/subsubdir
</pre>
As you can see, we are now creating two directories: one named <i>subdir</i> and
another one, included in this, named <i>subsubdir</i><br>
The -p flag is necessary to allow the shell to create intermediate
directories as required.<br><br>
<h3>Create directories with specified permissions</h3>
The <code>-m mode</code> option allows us to set permissions at the new directory
that we are now creating.
<pre>
mkdir -m 777 test_free_directory
</pre>
Our new directory will now have read,write and execute permissions for user, group and others.