mkdir and rmdir Commands in Linux

Back

The mkdir and rmdir commands are used to create and delete directories. The ways these commands are used depends are on the concept of absolute and relative paths.

For example :

The following command create the test sub-directory to the current directory . If you're currently in the /home/michael directory ,the full path would be /home/michael/test.

$ mkdir  test
   creates the test directory

$ mkdir -p /test1/test2/tes3
   create a series of directories.

The rmdir command deletes a directory only if it's empty . If you are cleaning up after the previous mkdir commands ,the -p switch is useful there as well. 
The following command deletes the directory and sub-directories ,as long as all of the directories are otherwise empty.

$ rmdir -p /tets1/test2/test3