Home > System Tutorial > LINUX > How to create a directory using linux commands

How to create a directory using linux commands

下次还敢
Release: 2024-04-11 18:12:21
Original
883 people have browsed it

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 using linux commands

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>
Copy after login

For example, to create a directory named "documentation ” directory, please run:

<code class="bash">mkdir 文档</code>
Copy after login

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>
Copy after login

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>
Copy after login

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>
Copy after login

Example:

The following example demonstrates how to create a different directory:

  • Create a directory named "temp" in the current directory:
<code class="bash">mkdir temp</code>
Copy after login
  • Create a directory named "html" in "/var/www" :
<code class="bash">mkdir /var/www/html</code>
Copy after login
  • Use the -p option to automatically create the parent directory:
<code class="bash">mkdir -p /var/www/projects/myproject</code>
Copy after login
  • Use -v Option to print verbose output:
<code class="bash">mkdir -v ~/Documents/NewFolder</code>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template