Create a Folder in Linux Using the Command Line: A Step-by-Step Guide – ITU Online IT Training

Create a Folder in Linux Using the Command Line: A Step-by-Step Guide

Ready to start learning? Individual Plans →Team Plans →

Need to create a folder Linux admins can trust, not guess at? The fastest way is usually the command line, and the core tool is mkdir. If you know how to use Linux commands for directory creation, you can organize files, build project trees, and automate workflows without opening a GUI.

Quick Answer

To create a folder in Linux from the command line, use mkdir, optionally add -p for nested paths, and verify with pwd and ls. The basic syntax is mkdir foldername, and it works in any writable location inside the Linux file system, including home directories and project paths.

Quick Procedure

  1. Check your location with pwd.
  2. Create one folder with mkdir foldername.
  3. Create a path with mkdir project/assets.
  4. Add parent folders with mkdir -p projects/web/app.
  5. Confirm the result with ls or tree.
  6. Use sudo only when system permissions require it.
Primary Commandmkdir
Common Options-p, -v, -m as of June 2026
Typical UseFolder and project directory creation as of June 2026
Permission ConcernSystem paths may require sudo as of June 2026
Verification Commandspwd, ls, ls -ld, tree as of June 2026
Best PracticeUse lowercase names with hyphens or underscores as of June 2026

Understanding Linux Directories

Directory is a container in the Linux file system used to organize files and other directories, while a file stores content such as text, code, or binary data. That distinction matters because directory creation is about structure, not content.

On Linux, the file system is arranged like a tree rooted at /. Common locations include home directories such as /home/alex, temporary storage in /tmp, and service or log data in /var. If you are learning a command line tutorial for the first time, the important idea is simple: folder location changes how Linux treats access, ownership, and persistence.

The current working directory is the folder your shell is using right now. If you type mkdir reports, Linux creates the folder in that current location, not somewhere random. That is why pwd matters; it tells you exactly where a command will act.

There are two ways to describe paths. An absolute path starts from the root, such as /home/alex/projects, while a relative path starts from your current location, such as projects/assets. If you are already in /home/alex, those paths can lead to the same place, but they behave differently when scripts run from different locations.

Folders are not just containers on Linux; they are part of the control system for permissions, automation, and workflows.

That is why folder creation is one of the first practical Linux skills people should learn. It shows up everywhere, from creating a home lab to staging a Kali Linux download for Windows 10 testing, setting up a firewall for Kali Linux notes, or organizing a lab for hacking with Linux in an authorized environment.

For reference, Linux filesystem behavior is documented in the official Linux Kernel file system documentation. If you also need the shell-side naming conventions and path rules, the glossary entry for Shell is useful background.

What Is the Basic Command to Create a Folder?

The basic command is mkdir, short for “make directory.” The simplest syntax is mkdir foldername, and it creates one new folder in the current directory.

For example, if you want to create a project folder, run:

mkdir project-notes

If the folder already exists, mkdir usually returns an error like “File exists.” That is a useful safety check because it prevents accidental overwrites. Linux treats duplicate directory names carefully, which is exactly what you want when organizing important work.

A clean naming style makes life easier later. Use descriptive names such as client-backup, lab-scripts, or training-notes. Avoid spaces when possible because spaces create quoting and escaping problems in the shell; if you must use them, wrap the name in quotes like mkdir "Quarterly Reports".

  • Good: mkdir web-assets
  • Good: mkdir finance_2026
  • Less ideal: mkdir My Folder
  • Problematic: mkdir folder! if later used in scripts or automation

The official mkdir manual page documents the syntax and options in detail. If you are building a habit for Linux commands, the rule is straightforward: create names that humans can understand and scripts can safely reuse.

How Do You Create Folders in Specific Locations?

You create a folder in a specific location by giving mkdir either an absolute path or a relative path. The command does not care whether you are making a folder in your home directory or deep inside a project tree; it only cares that the path is valid and writable.

To create a folder with an absolute path, use the full location from the root:

mkdir /home/alex/projects

To create a folder relative to your current location, use a path based on where you are now:

mkdir project/assets

That second example assumes the project directory already exists. If it does not, Linux throws an error because it cannot create assets inside something that is not there yet. This is one of the most common directory creation mistakes for new users.

Use pwd before you create folders when location matters:

pwd

Then confirm the result with ls:

ls

If you are building training labs, document trees, or development workspaces, this habit saves time. It also reduces confusion when you are switching between a home folder, a temporary directory, and system paths like /var or /tmp.

Note

Relative paths are convenient in scripts and project folders, but absolute paths are safer when the command must run from any location. Use the one that makes the intent obvious.

For path behavior and file-system layout, the GNU Coreutils pathname documentation is a practical reference. If you are mapping nested locations, the glossary term File System is also helpful.

How Do You Create Multiple Folders at Once?

You can create several directories in one command by listing them after mkdir. This is one of the fastest ways to build a consistent project layout, especially when you know the structure ahead of time.

Example:

mkdir docs downloads backups

That command creates three folders in the current directory. It is a simple way to bootstrap a workspace for documents, file transfers, or development work without repeating the command three times.

Using a project structure

If you are setting up a structured workspace, create folders that reflect the work rather than the tool. A clean layout might look like this:

mkdir -p project/{src,bin,config,logs}

That syntax uses shell expansion to create several similarly named folders at once. It is useful when you want a repeatable structure for code, logs, and configuration files. It also makes automation easier because scripts can assume the folders exist.

Why naming patterns matter

Choose consistent patterns such as lowercase names and hyphen-separated labels. Patterns like client-a, client-b, and client-c are easier to scan than a mix of abbreviations and random labels. The same logic applies when you are organizing test data, downloads, or backup directories.

  • Documents: mkdir -p work/{invoices,letters,policies}
  • Downloads: mkdir -p downloads/{images,archives,installs}
  • Development: mkdir -p app/{src,test,docs}

Shell expansion is not magic; it is just a shortcut the shell expands before mkdir runs. If you want more background on shell behavior, see the official GNU Bash Manual. That matters in real operations work, where repeatable folder creation is often part of a Linux boot camp exercise, a scripting task, or a lab for hacking Linux distro research in an authorized environment.

How Do You Create Nested Directories with -p?

The -p option tells mkdir to create parent directories as needed. If the intermediate folders do not exist, -p builds them automatically instead of failing.

Example:

mkdir -p projects/web/app

Without -p, that command fails if projects or web does not already exist. With -p, Linux creates the full path one level at a time. That is why -p is the option most people reach for in scripts, deployment jobs, and repeatable lab setups.

It is also safe to run on a path that already exists. If projects/web/app is already there, mkdir -p does not treat that as a problem. It quietly leaves the existing directories in place and moves on.

A practical example is a developer preparing a new application workspace:

mkdir -p ~/dev/clientX/{src,assets,tests,docs}

That single command can save several minutes every time a new project begins. It also lowers the chance of mistakes because one command creates the full structure consistently.

If you create nested folders often, -p is not optional convenience; it is the difference between reliable automation and repeated manual fixes.

For broader context on command behavior and path creation, the Red Hat Linux command-line basics material is a solid vendor reference. The official GNU and man-page documentation remains the best source for exact option behavior.

What Do You Do When Permissions Block Folder Creation?

Permission errors happen when your user account does not have write access to the target location. This is common in system directories such as /etc, /var, or other areas owned by root.

A typical error looks like this:

mkdir: cannot create directory ‘/opt/app’: Permission denied

That message means the path exists, but your account lacks the required rights. In those cases, you may use sudo if you truly need to create a folder in a protected location:

sudo mkdir /opt/app

Use elevated privileges carefully. Root access can create the wrong folder in the wrong place just as easily as the right one. If you are not sure, check ownership and permissions first:

ls -ld /opt

The output shows who owns the directory and what access flags are set. If the folder is meant for a service, system package, or server process, you may need to create it with root and then adjust ownership with chown afterward.

Warning

Do not use sudo just to make an error disappear. If you do not understand why a directory needs elevated privileges, stop and verify the path, ownership, and expected destination first.

For authoritative guidance on privilege management and secure operations, see NIST Cybersecurity Framework and the Linux permissions model described in the chmod manual page. If your work involves enterprise access control, the concepts also align with official security guidance from Microsoft® Learn at Microsoft Learn.

Three mkdir options show up constantly in real work: -v, -m, and -p. You have already seen -p; the other two are helpful when you want clearer output or specific permissions at creation time.

-v for verbose output

The -v option prints a message for each directory created. That is useful in scripts or long commands because it confirms what happened.

mkdir -v logs archive reports

-m for permissions

The -m option sets permissions when the directory is created. For example:

mkdir -m 755 shared

That makes the folder readable and searchable by everyone, while only the owner can write to it. Permission settings matter when multiple users, service accounts, or automation tools need controlled access.

Related commands you should know

  • rmdir: removes empty directories only.
  • rm -r: deletes a directory and its contents, so use it carefully.
  • touch: creates a file, not a folder.

That last distinction matters more than beginners expect. If you run touch reports, you create a file named reports, not a folder. If you need an actual directory for files, use mkdir.

For standards-based permission concepts and access control language, the CIS Benchmarks are a relevant technical reference. If your folder structure supports policy-driven environments, the official ISACA COBIT framework is also useful context.

What Are the Most Common Mistakes and How Do You Fix Them?

Most folder creation problems come from path mistakes, naming mistakes, or permission issues. The good news is that each one is easy to diagnose if you look at the error message instead of guessing.

Typos in names or paths

A typo in a path can point mkdir at the wrong location or make it fail entirely. If you type mkdir projec/assets instead of mkdir project/assets, Linux will not correct you. It will simply complain that the path does not exist.

Spaces in folder names

Spaces are legal, but they complicate shell commands. You can handle them with quotes or escapes:

mkdir "Quarterly Reports"

mkdir Quarterly Reports

That said, spaces create friction in scripts, backups, and automation. Hyphens and underscores are usually safer.

Missing parent directories

If a parent folder does not exist, a plain mkdir command fails. The fix is usually simple: add -p. For example, mkdir -p projects/app/logs creates the full path in one shot.

Permission problems

When you see “Permission denied,” check the target path with ls -ld and decide whether you should create the folder elsewhere. If the path really is a system location and you are authorized to modify it, then sudo may be appropriate.

Useful verification commands include pwd, ls, and tree if it is installed. A quick tree view helps confirm that the directory creation matched your intention, especially when you are building multiple nested folders.

In Linux, the fastest troubleshooting move is usually to restate the command in path terms: where am I, where am I writing, and who owns that location?

For broader operational guidance, CISA resources and the SANS Institute resources are strong references for secure administration practices. They are especially relevant when your directory work touches server hardening, logs, or automation inputs.

What Are the Best Practices for Folder Naming and Organization?

Good folder names make work easier six months later, not just today. A clean structure improves scripting, backup jobs, collaboration, and even incident response, because everyone can find the right location quickly.

Use names that describe purpose, not just timing. client-invoices is better than misc1, and backup-2026 is better than oldstuff. If you are building a larger Linux file system layout for projects or lab work, consistency matters more than creativity.

  • Use lowercase: it reduces typing mistakes and shell issues.
  • Prefer hyphens or underscores: they are easier to scan than mixed punctuation.
  • Avoid special characters: symbols can break scripts or require escaping.
  • Plan depth before creation: deep nesting is harder to maintain later.
  • Group by purpose: separate code, docs, logs, and exports cleanly.

If you work in teams, shared structure matters even more. Clear folder organization supports handoffs, reduces onboarding time, and makes it easier to automate repetitive tasks. That is true whether you are managing a simple home directory or a larger workspace used for end-user security training or end-user training materials.

For naming and documentation discipline, the ISO/IEC 27001 framework is a useful reference point. It reinforces the idea that organized information is easier to control, audit, and protect.

Key Takeaway

Use mkdir for basic folder creation, -p for nested paths, and pwd plus ls to verify location and results.

Use sudo only when the target path genuinely requires elevated permission.

Choose consistent folder names with lowercase letters, hyphens, or underscores so scripts and teammates can reuse the structure safely.

touch creates files, not folders, so do not use it when you need directory creation.

How Do You Verify It Worked?

Directory creation succeeded when the folder appears in the expected location and no error messages are returned. The easiest way to confirm that is to check the current path and then list the contents.

  1. Run pwd. This confirms where you are before you check the result. If the folder was meant to be created relative to your current directory, this step removes guesswork.
  2. Run ls. The new folder should appear in the listing. If you created hidden or nested directories, use ls -la or ls project to inspect the right level.
  3. Use tree if available. A tree view makes nested structures obvious, especially after mkdir -p. This is the fastest way to spot a missing level in a folder hierarchy.
  4. Check ownership with ls -ld foldername. This is important when you used sudo or created a folder in a shared location. Ownership tells you whether your user can write to it later.
  5. Look for common failure messages. “Permission denied” usually means access control, while “No such file or directory” usually means a bad path or missing parent folder.

If the folder is not there, do not start over blindly. Recheck the command, the path, and the permissions. That habit is more valuable than memorizing syntax because it turns every failure into a quick diagnosis.

For command-line verification details, the GNU Coreutils manual documents ls, pwd, and other basic tools. Those are the same commands you will rely on repeatedly in Linux administration, scripting, and troubleshooting.

Conclusion

Creating a folder in Linux from the command line is one of the most basic and most useful skills you can learn. The core pattern is simple: use mkdir for a single folder, use -p for nested directory creation, and check your permissions whenever the target location is protected.

If you remember only three commands, make them mkdir, pwd, and ls. That small set covers most directory creation tasks in the Linux file system, from a personal workspace in your home folder to a structured project tree or automation target.

Practice in a safe test directory first. Create a few folders in your home directory, try a nested path with -p, and verify the result with tree or ls. Repetition makes the command line feel faster because the process becomes muscle memory.

If you want more hands-on Linux commands practice, ITU Online IT Training recommends building simple folder structures until the workflow feels automatic. That is how directory creation stops being a task and starts being a habit.

CompTIA®, Microsoft®, AWS®, ISC2®, ISACA®, PMI®, and EC-Council® are trademarks of their respective owners.

[ FAQ ]

Frequently Asked Questions.

How do I create a new folder in Linux using the command line?

To create a new folder in Linux via the command line, you should use the mkdir command followed by the name of the folder you want to create. For example, typing mkdir myfolder will create a directory named “myfolder” in the current working directory.

This command is straightforward and compatible with most Linux distributions. Ensure you have the necessary permissions in the current directory to create new folders. If you encounter a permission denied error, you may need to use elevated privileges with sudo.

How can I create nested directories in Linux with one command?

To create nested directories in Linux simultaneously, use the -p option with the mkdir command. For example, mkdir -p parent/child/grandchild will create the entire directory tree, even if some of the parent directories do not yet exist.

This approach simplifies the process of building complex folder structures quickly. Without the -p option, mkdir will only create the specified directory and will error if any parent directories are missing. Using -p ensures all necessary parent directories are created as needed.

How do I verify that a folder has been created successfully in Linux?

After creating a folder, you can verify its existence by using the ls command. Typing ls will list all files and directories in the current directory, including the new folder.

If you want to check for a specific folder, use ls foldername or combine it with other options, such as ls -l for a detailed listing. Additionally, the pwd command shows your current directory path, helping confirm you’re in the correct location.

What permissions are set when I create a new folder in Linux?

By default, when you create a new folder in Linux, it inherits permissions based on your umask setting and the parent directory’s permissions. Typically, new directories are created with permissions like 755, meaning the owner has read, write, and execute permissions, while others have read and execute permissions.

You can modify permissions after creation using the chmod command. For example, chmod 700 foldername restricts access to only the owner, enhancing security for sensitive directories. Understanding and managing permissions is crucial for maintaining proper access control in Linux environments.

Are there any best practices for naming folders in Linux?

When naming folders in Linux, it’s best to use clear, descriptive names that reflect the folder’s purpose. Avoid spaces and special characters, as they can complicate command-line operations and scripting.

Common best practices include using lowercase letters, hyphens or underscores instead of spaces, and maintaining consistent naming conventions across projects. For example, use project_backup or reports-2024 for clarity and ease of use in scripts and automation tasks.

Related Articles

Ready to start learning? Individual Plans →Team Plans →
Discover More, Learn More
How to Make SQL Database : A Beginner’s Guide to SQL Create Database Command Learn how to create a SQL database and understand its role in… Using PowerShell Test-NetConnection for Network Troubleshooting: A Step-by-Step Guide Learn how to use PowerShell Test-NetConnection to efficiently troubleshoot network issues and… Step-by-Step Guide to Creating Interactive Power BI Dashboards Using Power Apps Visualizations Learn how to create interactive Power BI dashboards with Power Apps visualizations… A Step-by-Step Guide to Adding Users to Groups in Linux Discover essential Linux user management techniques to securely add users to groups,… Step-by-Step Guide to Managing Permissions With Chmod in Linux Discover how to effectively manage Linux file permissions with chmod to enhance… Securing Linux Servers With Proper Permissions: A Step-By-Step Guide Learn how to secure Linux servers by mastering permissions, ownership, and access…
FREE COURSE OFFERS