How to create a directory in Linux: Open a terminal window. Use the mkdir command, such as mkdir documentation to create the directory. Specify the parent directory, such as mkdir /var/www/html/newdir. Use the -p option to automatically create the parent directory, such as mkdir -p /var/www/html/newdir. Use the -v option to print verbose output, such as mkdir -v documentation.
How to create a directory in Linux
In the Linux operating system, a directory (folder) is an organization and The basic building blocks for storing files. The process of creating a new directory is simple and straightforward.
Steps:
1. Open the terminal
Use the shortcut Ctrl Alt T or search in the application launcher "Terminal" to open a terminal window.
2. Use the mkdir command
To create a directory, use the following command format:
<code class="bash">mkdir <目录名称></code>
For example, to create a directory named "documentation ” directory, please run:
<code class="bash">mkdir 文档</code>
3. Specify the parent directory (optional)
By default, the new directory will be created in the current directory. To specify a parent directory, prepend the path to the directory name:
<code class="bash">mkdir /var/www/html/newdir</code>
4. Use the -p option
If the parent directory does not exist, use The -p
(create parent directory) option automatically creates it:
<code class="bash">mkdir -p /var/www/html/newdir</code>
5. Use the -v option
if you want to see verbose output when creating the directory , you can use the -v
(verbose) option:
<code class="bash">mkdir -v 文档</code>
Example:
The following example demonstrates how to create a different directory:
<code class="bash">mkdir temp</code>
<code class="bash">mkdir /var/www/html</code>
-p
option to automatically create the parent directory: <code class="bash">mkdir -p /var/www/projects/myproject</code>
-v
Option to print verbose output: <code class="bash">mkdir -v ~/Documents/NewFolder</code>
The above is the detailed content of How to create a directory using linux commands. For more information, please follow other related articles on the PHP Chinese website!