Create Folder in Linux with Examples

Posted in

Create Folder in Linux with Examples
sangeeta.gulia

Sangeeta Gulia
Last updated on November 23, 2024

    You'll almost always need to create a new folder or directory when working with UNIX-like systems like Linux. As a result, you must be familiar with all of the ways to create a directory in Linux. We'll look at two methods for creating folders in Linux in this article. One is a graphical user interface (GUI), while the other is a command-line interface (CLI). Let's get started.

    Create Directory in Linux using GUI

    To create a new directory in Linux, right-click on the empty space where you wish to create it and select New Folder .

    New Folder

    Type the name of the directory. Here, we type “demo” as the name.

    Demo Folder

    Click on Create, and you will see the folder created in the current location.

    Create Folder

    Create Folder in Linux using mkdir command

    mkdir stands for ‘Make Directory’. In UNIX-like systems, the mkdir command creates a folder or directory(in UNIX terms) at the specified address or location, or in the current directory. For example, if you type mkdir demo in your machine's Desktop folder, it creates a directory called ‘demo’ in your Desktop. It will generate an empty directory by default. If you are not the root user, you may need some writing rights before creating new directories.

    The syntax of the mkdir command is:

    $ mkdir options directories

    Options with mkdir command

    • The –help options provides you with all the flags and information that you can use with the command. Below is the syntax for the command:
    $ mkdir –help

    mkdir help

    • The -v option displays the message in the terminal after the creation of the directory. Here is the syntax of the command:
    $ mkdir -v demo

    mkdir demo

    • The -m option allows you to create directories along with different permissions on it. The permissions can be read, write or execute. Let’s see how we use this option with the command:
    $ mkdir -m a=rwx

    mkdir m a rwx

    • The -p option allows you to create subdirectories and parent directories with executing the command only once. For instance, if you need to create a new directory named ‘demo1’ and another directory named ‘demo2’ inside ‘demo1’, you can use the -p option.
    $ mkdir -p demo1/demo2

    mkdir p demo1 demo2

    Conclusion

    We looked at various methods for creating directories in Linux in this article. The first was a GUI-based approach, which was rather basic and usually ideal for beginners because all we had to do was right-click and select an option. The second method, which uses mkdir command, is commonly used with Linux and is the only option when working with terminal-based Virtual Machines. The mkdir command also has a number of useful features for developers, such as alerts, permissions, and nested directory creation.

    People are also reading:

    Leave a Comment on this Post

    0 Comments