how to create a folder in linux terminal

How to Create a Folder in Linux Terminal

By Kevin Lee
AD

In the dynamic world of Linux, the terminal is more than just a command line tool - it's a powerful interface that enables you to interact with your system in ways not possible with a graphical user interface (GUI) alone. Among the many tasks you can perform in the Linux terminal is creating folders, a process that's not only faster but also more efficient once you get the hang of it. Let's delve into how to create a folder in the Linux terminal.

Before we dive into the process, it's crucial to have a basic understanding of the Linux file system hierarchy. The root directory, denoted by a single slash (/), is the top-level directory in Linux, with various subdirectories branching out from it. Knowing this hierarchy will help you place your newly created folders in the correct locations.

Navigating the Terminal

Before you can create a folder, you need to navigate to the directory where you want to create it. The commands Pablo and cd are extensively used for navigating the Linux file system.

AD
How to create a file in Linux using Terminal | ION HowTo
How to create a file in Linux using Terminal | ION HowTo
Linux Desktop & Terminal Explained | GUI, CLI, Shell & Essential Commands
Linux Desktop & Terminal Explained | GUI, CLI, Shell & Essential Commands
🐧 Linux File System — A Beginner-Friendly Guide
🐧 Linux File System — A Beginner-Friendly Guide

pwd is an alias for 'print working directory' and displays the full path of your current location in the file system. It's a handy command for verifying where you are.

Moving Around

The cd command, or 'change directory', is used to navigate the file system. For instance, to move into the 'Documents' directory, you would type cd Documents.

the linux file system has many different types of information on it, including text and images
the linux file system has many different types of information on it, including text and images
Learn Linux from Beginner to Advanced (Part-1) | Essential Terminal Commands Cheat Sheet
Learn Linux from Beginner to Advanced (Part-1) | Essential Terminal Commands Cheat Sheet
Linux Commands Cheat Sheet | Essential Terminal Commands for Beginners
Linux Commands Cheat Sheet | Essential Terminal Commands for Beginners

You can use cd .. to move up one level in the directory hierarchy, while cd / takes you directly to the root directory.

Changing Directories

You can also change directories using relative paths. For example, if you're in the 'Home' directory and want to move into the 'Music' directory within the 'Documents' folder, you would use cd Documents/Music.

AD

Moreover, you can create shortcuts for long directory paths using the Əlias command, which can save you time and keystrokes.

Linux Terminal NotesBook
Linux Terminal NotesBook
Linux File System Hierarchy Map: What Each Folder Does (Beginner Guide)
Linux File System Hierarchy Map: What Each Folder Does (Beginner Guide)
Linux Commands Cheat Sheet: Essential Commands Every Beginner Should Know
Linux Commands Cheat Sheet: Essential Commands Every Beginner Should Know
Linux Commands That Feel Like Magic | Useful Terminal Tricks for Beginners
Linux Commands That Feel Like Magic | Useful Terminal Tricks for Beginners
Basic Linux Commands Cheat Sheet for Beginners 🐧 | Linux Commands
Basic Linux Commands Cheat Sheet for Beginners 🐧 | Linux Commands
Linux File System Explained | /home, /etc, /usr, /var & More
Linux File System Explained | /home, /etc, /usr, /var & More

Creating a New Folder

Now that you're familiar with navigating the Linux file system, let's explore how to create a new folder, or directory, in the Linux terminal.

The basic command to create a new directory is mkdir, which stands for 'make directory'. For example, to create a new folder named 'Projects', you would type mkdir Projects.

AD

Creating a Single Directory

If you only need to create one directory, the basic mkdir command is sufficient. This command creates the directory in the current working directory.

BAT Command in Linux Made Easy (Complete Guide)
BAT Command in Linux Made Easy (Complete Guide)
Linux File System Hierarchy Map: What Each Folder Does (Beginner Guide)
Linux File System Hierarchy Map: What Each Folder Does (Beginner Guide)
the linux folders structure is shown in this screenshote screen shot, with text below
the linux folders structure is shown in this screenshote screen shot, with text below

To confirm that the directory has been created correctly, you can use the ls command. This shows a listing of all files and directories in your current location, making it easy to spot your newly created folder.

Creating Multiple Directories

You can also create multiple nested directories at once using mkdir. To do this, you simply separate each directory with a forward slash, like so: mkdir dir1/dir2/dir3.

AD

This command creates three nested directories - 'dir1', 'dir2', and 'dir3' - in one fell swoop, making it a time-saving feature for more complex folder structures.

In summary, the Linux terminal offers a powerful and efficient way to create folders and manage your file system. Whether you're a seasoned Linux pro or a keen beginner, grasping these commands will not only boost your productivity but also give you a more intimate understanding of how Linux works under the hood.

So, go forth and explore the Linux file system, armed with the knowledge of how to create and navigate directories with confidence and ease. Happy coding!

AD