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
936 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:

mkdir <目录名称>
Copy after login

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

mkdir 文档
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:

mkdir /var/www/html/newdir
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:

mkdir -p /var/www/html/newdir
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:

mkdir -v 文档
Copy after login

Example:

The following example demonstrates how to create a different directory:

  • Create a directory named "temp" in the current directory:
mkdir temp
Copy after login
  • Create a directory named "html" in "/var/www" :
mkdir /var/www/html
Copy after login
  • Use the -p option to automatically create the parent directory:
mkdir -p /var/www/projects/myproject
Copy after login
  • Use -v Option to print verbose output:
mkdir -v ~/Documents/NewFolder
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:
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 Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template