As you work with files, you'll need to organize them into directories. The primary tool for this task is the mkdir command, which stands for "Make Directory". This command allows you to create a directory in Linux right from your terminal or command prompt.
Creating a Single Directory
The most basic use of the mkdir command in Linux is to create a single new directory. If the directory doesn't already exist, this command will create it in your current location. For example, to create a directory named documents:
mkdir documents
Creating Multiple Directories
You can also create several directories at once by listing their names, separated by spaces. This is an efficient way to set up multiple folders quickly.
mkdir books paintings
Creating Nested Directories
Sometimes you need to create a directory and its parent directories simultaneously. The -p (parent) option is perfect for this. This powerful feature of the create folder Linux command prevents errors if parent directories don't exist. For instance, to create the directory favorites inside hemmingway, which is inside books:
mkdir -p books/hemmingway/favorites
This single command creates books, hemmingway, and favorites if they don't already exist, demonstrating a key capability when you need to create a directory in Linux.