You have decided to dive into the world of Linux and are wondering how to create and delete folders? Don't worry! In this guide, I will show you step by step how to do this via the terminal. We will use the commands mkdir to create folders and rmdir as well as rm -r to delete folders. Whether you want to learn the basics of a terminal command or have specific information about the various options at hand, you will find everything you need here.
Key Insights
- With the command mkdir you create folders.
- The command rmdir deletes empty folders.
- The command rm -r removes folders including their contents.
- Linux distinguishes between uppercase and lowercase.
- Wildcards can be used to process multiple files and folders.
Step-by-Step Guide
Step 1: Open Terminal and Navigate
First, open the terminal on your Linux system. Once you have opened the terminal, you can navigate to the location where you want to create the folder, for example, into the "Documents" directory. You can do this easily with the command cd Documents.

Step 2: Create Folder with mkdir
To create a new folder, you use the command mkdir, followed by the name of the folder you want to create. For example, you can use the following command:
If the folder should have spaces in its name, you need to put it in quotes:
Don't forget that Linux is case-sensitive! This means that "Testfolder" and "testfolder" are considered two different folders.

Step 3: Check the Folder via ls
To ensure that the folder was actually created, you can enter the command ls. This command lists all files and folders in the current directory, allowing you to see if "Testfolder" or "Test Folder" was successfully created.
Step 4: Delete Folder with rmdir
To delete an empty folder, you can use the command rmdir. This works as long as the folder contains no files or subfolders. For example:
However, if the folder has contents, you will receive an error message stating that the directory is not empty.

Step 5: Dealing with Non-Empty Folders
If you try to delete a non-empty folder, you first need to remove the files within that folder. You can delete the files manually, or if you want to delete all contents in one step, use the command rm -r:
This deletes the folder along with all files contained within it.

Step 6: Use of rm -rf
If you want to remove a folder and its entire structure without receiving a prompt, you can use rm -rf. Be careful with this command as it deletes all contents irreversibly:
This command is particularly useful when you want to delete many files at once without the confirmation prompt.

Step 7: Use of Wildcards
You can use wildcards to delete multiple folders or files simultaneously. For example, you could use the following command to remove all folders beginning with "Test":
This deletes any folder or file whose name starts with "Test" without prompting for confirmation.
Summary – Creating and Deleting Folders in Linux
In this guide, we have dealt with creating and deleting folders in Linux. You have learned how to use the commands mkdir, rmdir, and rm -r. These fundamental commands are essential for working in the terminal and will help you interact with your system efficiently.
Frequently Asked Questions
What role does case sensitivity play in Linux?Linux distinguishes between uppercase and lowercase. This means that folders with different spellings are considered different folders.
What happens if I try to delete a non-empty folder with rmdir?rmdir can only delete empty folders. For non-empty folders, you will receive an error message.
How can I delete a folder with all its contents?Use the command rm -r followed by the folder's name to delete it along with its contents.
How can I delete multiple folders at once?Use wildcards like * to delete multiple folders at the same time. For example: rm -r Test*.
Is it safe to use rm -rf?Yes, but be cautious. This command deletes everything without prompting for confirmation, so be sure you won't lose any important files.