🎓 A1Learner
🔍
0 of 50 lessons completed

Shell Making Folders

Making folders means creating new places for files. mkdir makes one folder at a time.

Make a folder

mkdir makes a folder named practice. ls -d names the folder itself.

mkdir practice
ls -d practice

Nested folders fail

This fails. The shell answers: mkdir: cannot create directory 'deep/nested': No such file or directory

mkdir deep/nested

Make nested folders

mkdir -p makes nested folders in one step. Nested folders sit inside each other, like work/notes.

mkdir -p work/notes
ls -d work work/notes

Example

mkdir -p practice work/notes
ls -d practice work work/notes

Key points

  • mkdir: the command that makes a new folder.
  • Use mkdir practice to make a folder named practice.
  • Use mkdir -p to make nested folders in one step.

In this example, the first line makes practice and the nested work/notes. The second line names the three folders it made.

Note

Plain mkdir fails when the parent folder does not exist yet.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which command makes nested folders in one step?