
- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to create a new directory in Linux using the terminal?
The mkdir command is used to create a new directory in the Linux/Unix operating system. It is also used to create more than one directory at a time and set the permission for the directories just like the chmod command in the Linux system.
Syntax
The general syntax of the mkdir command is as follows −
$ mkdir [OPTION]... [DIRECTORIES]...
Brief description of options available in the mkdir command.
Sr.No. | Option & Description |
---|---|
1 | -m, --mode=MODE Set the mode of file as the time of directory creation just like the chmod command |
2 | -p, --parents No message prompt if existing and make parent directories as needed |
3 | -v, --verbose Print what is being done |
4 | -Z By default, set the SELinux security context of each created directory |
5 | --help Displays a help message and then exits. |
6 | --version It gives info about the version and then exits. |
To create a new directory in the Linux/Unix operating system using terminal, we use mkdir (make directory) command as shown in below.
$ mkdir newdir
After executing this command, a new directory will be created with the “newdir” name in the current director.
The mkdir command is also used to create multiple directories at time as shown in below.
$ mkdir dir1 dir2 dir3 dir4...
To create a parent directory and child directory using -p or --parents option and print a message that what is being done using -v or --verbose option along with the mkdir command in the Linux system as shown in below.
$ mkdir --parent --verbose parent/child mkdir: created directory ‘parent’ mkdir: created directory ‘parent/child’
After executing the above command, a new directory is created as well a child directory also created inside the parent directory.
To create directory and set permission at the time of creation, we use -m or --mode option with the mkdir command.
$ mkdir -m 400 newdir
To check the version information of the mkdir command run below command.
$ mkdir --version
To check more details about options about the mkdir command execute --help option with the mkdir command.
$ mkdir --help
Note – It is mandatory to owner permission to create a directory in the parent directory otherwise an error will be “prompt permission denied”.
- Related Articles
- How to Create a File in the Linux/Unix system using terminal?
- How to create key binds in the Linux system using the terminal?
- How to create a new directory by using File object in Java?
- How can I create directory tree using C++ in Linux?
- How to Create a Shared Directory for All Users in Linux?
- How to open a new pseudo-terminal pair using Python?
- How to decorate your Linux Terminal using Shell?
- How to create a directory using Python?
- How to create a directory using Java?
- How to create a Directory using C#?
- How to create an Animated Art on Your Linux Terminal?
- How to Create a New Ext4 File System in Linux?
- How to Create a New File in Linux from Bash?
- How to create a zip file and ignore directory structure in Linux?
- How to copy files to a new directory using Python?
