HOW TO CREATE DIRECTORIES ON THE UBUNTU TERMINAL

How to Create Directories on the Ubuntu Terminal

How to Create Directories on the Ubuntu Terminal

Blog Article


How to Create Directories on the Ubuntu Terminal


Ubuntu, a popular Linux distribution, offers a powerful command-line interface (CLI) known as the terminal. One of the most common tasks you might need to perform in the terminal is creating directories (folders). Whether you're setting up a new project, organizing files, or managing a server, knowing how to create directories efficiently can save you a lot of time and effort.

Basic Command: mkdir


The primary command used to create directories in Ubuntu is mkdir, which stands for "make directory." Here’s a quick guide on how to use it:

Creating a Single Directory


To create a single directory, use the following command:
mkdir directory_name

For example, to create a directory named projects, you would run:
mkdir projects

Creating Multiple Directories


You can create multiple directories at once by listing them all after the mkdir command, separated by spaces:
mkdir directory1 directory2 directory3

For example, to create documents, music, and videos, you would run:
mkdir documents music videos

Creating Nested Directories


If you need to create a directory structure with multiple levels, you can use the -p (parent) option. This option ensures that all parent directories are created if they do not already exist.
mkdir -p path/to/directory

For example, to create a directory structure like projects/2023/01, you would run:
mkdir -p projects/2023/01

This command will create the projects, 2023, and 01 directories if they do not already exist.

Verifying Directory Creation


After creating a directory, you can verify its existence using the ls command, which lists the contents of a directory:
ls

To see the full path of the directories you created, you can use the pwd (print working directory) command followed by ls:
pwd
ls

Additional Tips



  • Permissions: By default, the mkdir command creates directories with read, write, and execute permissions for the owner, and read and execute permissions for the group and others. You can change these permissions using the chmod command.

  • Help and Documentation: For more detailed information about the mkdir command, you can use the man (manual) command:
    man mkdir



This will open the manual page for mkdir, providing you with a comprehensive guide to its usage and options.

Conclusion


Creating directories in the Ubuntu terminal is a straightforward process with the mkdir command. Whether you need to create a single directory, multiple directories, or a nested directory structure, the mkdir command provides the flexibility and power to get the job done efficiently.

For more detailed information and additional tips, you can refer to the official guide on how to create directories on the terminal in Ubuntu.

Happy directory management!

Report this page