A directory is a location for storing files on your computer. To be able to administer your Linux distribution, you need to be familiar with commands that let you create, delete or move directories.
In Linux there’s only one root directory (represented by a single slash, “/“), and all files and subdirectories are placed under the root directory in a treelike structure.
To create a directory, you use the mkdir command:
To move a directory, you use the mv command with two parameters. The first paramter is the directory you would like to move and the second paramter is the location where you would like to move the directory to. For example, if we want to move the directory named my_folder to/home/bob/my_folder1 we would enter the following command:
To delete a directory we need to use the rmdir command. There is one problem with this command, though. If we try to delete a non-empty directory, we will get an error:
To avoid this we need to either empty the directory or use the different command, rm. If we use the rm command we also need to specify the -r option, which means that the command will remove the directory and its content recursively:
Post a Comment