Working on Linux Directory - Basic Commands
Working on Directories in Linux:
In this articles we gonna see some useful commands while working on files and directory in a Linux system.
Directory:
The directory is the place where files and subdirectories are created. While coming in GUI we call a directory as a folder. A directory can hold more sub-directories or sub-folders inside it.
In Linux the / is known as the root directory where everything on your Linux system is located under this directory.
Creating directory:
To create a directory use mkdir command,
The above commands creates two directories as Dir1 and Dir2,
Creating Consecutive directory:
To create consecutive directory use -p command with mkdir, this allows you to create sub-directory inside a directory.
The above command creates all subdirectories in a single command.
Toggling between Directories:
Use cd command to change from active directories, Let us assume you are creating the above directories in /home directory. Now you want to enter into Dir1. The command to change your current working directory is,
To move to the previous directory use cd -
To move one directory back use .. with cd
To move two directory back use ../.. with cd
cd command will get you back to the root directory.
Knowing the current working directory:
To print the current working directory use pwd
Deleting a Directory:
The command use to delete a directory is rm -rf , This command will delete all the subdirectories inside the directory. Beware of using rm -rf command since it will never ask for a confirmation.
Feel free to ask if you have any questions.
Comments