100 Useful Command-Line Utilities

by Oliver; 2014

5. mkdir, rmdir

To make directory—i.e., create a new folder—we use:
$ mkdir mynewfolder
To make nested directories (and don't complain if trying to make a directory that already exists), use the -p flag:
$ mkdir -p a/b/c  # make nested directories
You can remove directory using:
$ rmdir mynewfolder  # don't use this
However, since the directory must be empty to use this command, it's not convenient. Instead, use:
$ rm -r mynewfolder  # use this
Since rm has all the functionality you need, I know few people who actually use rmdir. About the only occasion to use it is if you want to be careful you're not deleting a directory with stuff in it. (Perhaps rmdir isn't one of the 100 most useful commands, after all.)

<PREV   NEXT>