How to Create a New Folder using the Terminal on Linux Mint

Share
In this tutorial, we'll learn how to create a new folder (a new directory) with the terminal on Linux Mint using the mkdir command.

To create a new folder, execute the following terminal command [how?]:

mkdir new-folder

This will create a new folder in the current working directory called new-folder. See [How to Refer to Files and Folders using the Terminal on Linux Mint] for how to write this filename argument.

Tip: you can create multiple directories at once by passing mkdir multiple positional arguments. For example mkdir a b will create 2 directories.

Tip: you can create subdirectories with the option --parents (-p). For example mkdir -p a/b/c/d/e/f will create six f and all its parents directories if they don't already exist.

Questions and Answers

What Happens if the Target of mkdir Already Exists?

If the target of mkdir is already an existing file or folder, you'll get an error that says "mkdir: cannot create directory ‘new-folder’: File exists" Exceptionally, if the option --parents is provided, an error message won't be displayed.

What Happens if You mkdir a Symlink?

If the target of mdkir is a symlink, you'll ALSO get an error that says "mkdir: cannot create directory ‘new-folder’: File exists". This is rather surprising, as you can use touch to create an empty file, and using it with a symlink that points to a non-existing file will create it.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments