Table of Contents
Open Table of Contents
- Introduction
- Basic Usage of mkdir
- Common Use Cases
- Advanced mkdir Techniques
- Common Errors
- Conclusion
Introduction
The mkdir
command is used to create directories in Linux. It is a fundamental command for organizing files and directories.
Basic Usage of mkdir
Syntax
The basic syntax of mkdir
is:
mkdir [options] directory_name
Example
To create a directory named “new_folder”:
mkdir new_folder
Common Use Cases
- Creating Nested Directories: Use the
-p
option to create parent directories as needed.mkdir -p parent/child/grandchild
Advanced mkdir Techniques
Setting Permissions
You can set permissions while creating a directory using the -m
option.
mkdir -m 755 new_folder
Common Errors
- Directory Exists: If the directory already exists, you will receive an error.
- Permission Denied: Ensure you have the necessary permissions to create a directory in the specified location.
Conclusion
Understanding the mkdir
command is essential for effective file organization in Linux.