Learning

Linux for Starters: Your Guide to Linux – Manipulating Files – Part 13

Last Updated on May 22, 2022

mkdir

mkdir is a command that creates a directory.

We can create a directory in current directory or given path with the command:

$ mkdir directory

Create directories recursively (useful for creating nested dirs):

$ mkdir -p path/to/directory

The mkdir command is used to create directories.

We can create a directory in the current directory or given path with the command:

$ mkdir dir1

Remember that Linux is case-sensitive. So we can have directories with names dir2, Dir1, DIR1 etc.

It’s also possible to create directories recursively. This lets us create nested directories with a single command: For example, let’s suppose we are in ~/test, and execute the command:

$ mkdir -p mkdir -p dir1/dir2/dir3

The tree command shows the new directories we’ve created.

sde@medway:~/test$ tree
.
└── dir1
    └── dir2
        └── dir3

The command rmdir removes a directory. It can only remove empty directories,

To remove directories containing sub-directories (providing they have no files) we can use the command:

$ rmdir -p dir1/dir2/dir3

Removing a directory using a shell command doesn’t place it in the Rubbish Bin. It’s gone forever.

Pages in this article:
Page 1 – cp
Page 2 – mv
Page 3 – rm
Page 4 – mkdir


All articles in this series:

Linux For Starters: Your Guide to Linux
1What is Linux? Why use Linux? What do I need?
2Choose a Linux distribution meeting your specific needs and requirements.
3Make a bootable Ubuntu USB stick in Windows.
4We show you how to install Ubuntu 21.04 on your hard disk.
5Things to do after installing Ubuntu.
6Navigating your way around the Desktop.
7Updating the system, install new software.
8Open source replacements for proprietary Windows desktop software.
9Get started with the power and flexibility of the terminal.
10We cover the basics of files and permissions.
11Getting help from your system.
12Learn all about the file system.
13Manipulating files from the shell.
14Maintain your system with these simple tips.
15Managing users on your system.
16Explore different desktops to GNOME 3.
17Gaming on Linux.
18Protect your privacy with this guide.
19Access the Windows desktop from Linux using a remote desktop client.
20Set up a virtual machine running Ubuntu as the host and openSUSE as the guest.
21Wine lets you run Windows programs on Linux without emulation.
22Extend your GNOME desktop with extensions and themes.
XUseful Linux commands.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
D Watson
D Watson
2 years ago

Thanks. How many parts will this guide be?