How to use the Linux mkdir
command plus essential options
In this installment of “Conquer The Command Line” we talk about how to use the Linux mkdir
command.
When ever you want to create a new directory, use the mkdir
command.
Memory Aid: Think “make directory”
To make a directory type mkdir
followed by the name of the directory. For instance, mkdir docs
.
Essential Options
-p: create directories recursively. That means create all the directories on the way to and including the last one in the path. The path is the road to the directory at the end.
Above we have an example of creating a directory called docs. if you had not created a directory called docs, but wanted to create a directory called docs, and a directory called history inside the one called docs, you would have to type mkdir -p docs/history
.
Think of the slash as the road that connects the directories. For Windows people, Linux uses a /
rather than a \
to display the path. The /
is called the path separator.
Once you make a directory, you can use cd to change to, or move into it. You can use pwd to display or print its name. You can use ls to list its contents. Remember to use the man command to find all the options for any command on your system.
What Now?
Hopefully this post has helped you take one more step in conquering the command line. I welcome any feedback.
This post was originally written at https://www.jimhomme.com