mkdir is a core linux command-line utility that is used to create a directory. There are a few ways you can make use of the linux tool mkdir
How to use mkdir
# syntax, options = optional
mkdir <OPTIONS> <DIRECTORYNAME>
##### create directory, with parameters and without
mkdir test # create a directory named test
mkdir -p test/test1241/testing/hamburgers # creates the directory structure test/test1241/testing/hamburgers
mkdir /root/testdir # creates the directory testdir in the root directory
mkdir -m 700 # create a directory where only the owner has the permissions to move, rename or delete the directory
mkdir test1 test2 test3 # create 3 directories in the current directory you're in. These are named test1, test2, test3
mkdir examples
root@Corrosie:~/Desktop/test# ls
root@Corrosie:~/Desktop/test# mkdir testDirectory
root@Corrosie:~/Desktop/test# ls
testDirectory
root@Corrosie:~/Desktop/test# mkdir -p test/test1/test2/test3
root@Corrosie:~/Desktop/test# tree ./
./
├── test
│ └── test1
│ └── test2
│ └── test3
└── testDirectory
5 directories, 0 files
root@Corrosie:~/Desktop/test#
What is rmdir?
rmdir is the opposite of mkdir, rmdir is used to delete empty directories.
(checkout rm if you want to delete directories with content, you can't achieve this with rmdir)
How to use rmdir
# syntax, options = optional
rmdir <OPTIONS> <DIRECTORY>
rmdir test # removes the directory test
rmdir -p test/test1241/testing/hamburgers # remove the directory structure test/test1241/testing/hamburgers
rmdir test test1 test2 test3 # removes the 4 directories : test test1 test2 and test3
rmdir /root/testdir # removes the directory testdir from the root directory
rmdir examples
root@Corrosie:~/Desktop/test# ls
root@Corrosie:~/Desktop/test# mkdir test
root@Corrosie:~/Desktop/test# ls
test
root@Corrosie:~/Desktop/test# mkdir test1 test2 test3
root@Corrosie:~/Desktop/test# ls
test test1 test2 test3
root@Corrosie:~/Desktop/test# rmdir test test1 test2 test3
root@Corrosie:~/Desktop/test# ls