Home  >  Article  >  System Tutorial  >  What are the commands to create a folder in Linux?

What are the commands to create a folder in Linux?

下次还敢
下次还敢Original
2024-04-12 13:36:44598browse

Common commands to create folders in Linux include: mkdir: Create a new folder. touch: Create the folder if it does not exist. install: Copy files or create directories. umask: Set the permission mask to create a full permission (777) folder. xargs: Input through pipes and create folders.

What are the commands to create a folder in Linux?

Linux folder creation command

In Linux systems, you can use a variety of commands to create folders. The following are some commonly used commands:

1. mkdir command

  • ## Syntax: mkdir [options] Folder name
  • Description: Create one or more folders.
  • Example: Create a folder named "new_folder":

    <code class="shell">mkdir new_folder</code>

2. touch command

  • Syntax: touch [options] Folder name
  • Description: Create the folder if it does not exist.
  • Example: Create a folder named "existing_folder" if it does not exist:

    <code class="shell">touch existing_folder</code>

3. install command

  • Syntax: install [options]/path/to/source/path/to/target
  • Description: Copy files or create directories (including folders).
  • Example: Create a folder named "duplicate_folder" and copy the contents of "source_folder":

    <code class="shell">install -d /source_folder /duplicate_folder</code>

4. umask command

  • Syntax: umask [option] [mode]
  • Description: Modify files and The default permission mask for the folder. By setting the mask to 000, you can create a folder with permissions 777 (full read, write, execute).
  • Example: Create the folder "new_folder_with_full_permissions" with permission 777:

    <code class="shell">umask 000
    mkdir new_folder_with_full_permissions</code>

5. xargs command

  • Syntax: find [condition] | xargs mkdir
  • Description: Receive from another command (such as find) through a pipe Enter and use the mkdir command to create the folder.
  • Example: Create folders for all subdirectories under the "project_dir" directory:

    <code class="shell">find project_dir -type d -print0 | xargs -0 mkdir</code>

The above is the detailed content of What are the commands to create a folder in Linux?. For more information, please follow other related articles on the PHP Chinese website!

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