How to Create a Folder in Linux: Commands, Options, and What to Know

Creating a folder in Linux is one of the most fundamental file system operations you'll perform — whether you're organizing project files, setting up a server directory structure, or scripting automated workflows. Linux gives you several ways to do it, and understanding the differences between them will save you time and prevent permission headaches down the line.

The Core Command: mkdir

The primary tool for creating folders in Linux is mkdir — short for "make directory." It works across virtually every Linux distribution and shell environment.

The basic syntax is:

mkdir folder_name 

This creates a new folder in your current working directory. If you're not sure where you are in the file system, running pwd (print working directory) first is a good habit.

You can also create a folder in a specific location by providing the full or relative path:

mkdir /home/username/Documents/projects 

Creating Multiple Folders at Once

mkdir can create several folders in a single command by listing them with spaces between names:

mkdir folder1 folder2 folder3 

This is particularly useful when scaffolding out a project structure quickly.

Creating Nested Folders with -p

One of the most useful flags is -p (parents). Without it, if you try to create a folder inside a directory that doesn't yet exist, Linux throws an error. With -p, it creates the entire path as needed:

mkdir -p projects/2024/reports/final 

If projects, 2024, or reports don't already exist, Linux creates all of them in sequence. This is especially valuable in shell scripts where you can't guarantee the directory structure already exists.

Setting Permissions When You Create a Folder 🗂️

By default, new folders inherit permissions based on your umask setting — a system-level mask that subtracts from the maximum possible permissions. On most Linux systems, this results in newly created directories having permissions of 755 (owner can read, write, execute; group and others can read and execute).

If you need different permissions from the start, use the -m flag:

mkdir -m 700 private_folder 

This creates the folder with permissions set to 700 — meaning only the owner can access it. This is relevant for:

  • Sensitive data directories where other users on the system shouldn't have access
  • Web server directories where specific permission structures are required
  • Shared environments like corporate servers or university computing systems

You can always change permissions later with chmod, but setting them at creation time is cleaner in automated scripts.

Using a File Manager (GUI Approach)

Not every Linux user works exclusively in the terminal. Most desktop environments — including GNOME, KDE Plasma, and XFCE — come with graphical file managers where you can right-click in a directory and select "New Folder" just as you would on Windows or macOS.

This approach is perfectly valid for desktop users who aren't running servers or writing scripts. The underlying operation is identical — the GUI is simply calling the same system-level functions as mkdir.

Variables That Affect How You Should Create Folders

The "right" approach depends on several factors that vary from one user to the next:

VariableWhy It Matters
Shell environmentBash, Zsh, Fish, and others all support mkdir, but shell scripts may handle quoting or path syntax slightly differently
User permissionsStandard users can only create folders where they have write access; creating folders in /etc, /usr, or system directories requires sudo
DistributionCore commands like mkdir are universal, but file paths and default directory structures differ between Ubuntu, Fedora, Arch, Debian, and others
Use caseInteractive use, shell scripting, and configuration management (like Ansible) each have preferred patterns
Multi-user environmentOn shared systems, group ownership (chown, chgrp) and sticky bits may matter as much as the folder creation itself

When sudo Is Required

If you try to create a folder in a location where your user account doesn't have write permission, you'll see a "Permission denied" error. Prepending sudo runs the command with elevated privileges:

sudo mkdir /etc/myapp 

Use sudo only when necessary. Creating folders inside your home directory (/home/username/) never requires it under normal circumstances.

Folder Naming: What Linux Allows and What to Avoid 🐧

Linux file systems are largely permissive about folder names — spaces, special characters, and mixed case are all technically allowed. But in practice:

  • Spaces in folder names require quoting or escaping (mkdir "my folder" or mkdir my folder) and create friction in scripts
  • Special characters like !, #, &, or * can interfere with shell interpretation
  • Case sensitivity matters — Documents, documents, and DOCUMENTS are three distinct folders on a Linux system (unlike Windows)

Most experienced Linux users stick to lowercase letters, numbers, hyphens, and underscores for folder names used in scripts or server environments.

The Difference Between Interactive and Scripted Use

When you're working in a terminal session, a simple mkdir folder_name is usually all you need. In scripts, the considerations shift:

  • Use -p to avoid errors when directories may or may not already exist
  • Use -m to set explicit permissions rather than relying on umask defaults
  • Check exit codes — mkdir returns 0 on success and a non-zero value on failure, which scripts can use for error handling

The combination of these flags (mkdir -pm 755 path/to/folder) is common in deployment scripts and dotfile configurations precisely because it handles edge cases without requiring extra error-checking logic.

Whether you're setting up a home directory, structuring a development project, or configuring a server, the approach that makes the most sense depends on your distribution, your permission environment, and whether you're working interactively or inside a script. Those specifics are what determine which combination of flags and paths actually fits your situation.