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

Popular Posts on this blog

Apache Webserver - Installation from source (tar.gz and tar.bz2)

Setting up a Mail server using Roundcube - Part-1 - Centos 7

How to Install LAMP Stack on Linux - Centos 7

Apache Tomcat Installation - Ubuntu - 17.04

Installing Docker-Compose on Ubuntu

Setting up a Mail server using Roundcube - Part-3 - Centos 7

Blog Top Sites

Blog Log