How to Move Folder Using Terminal

In the previous part of the tutorial, we have learned about How to View the Contents of a Folder by using the command ls.

Next we will learn how to enter into a folder, exit a folder or move to a folder using the command CD“cd” itself stands for change directories.

Immediately, for example you are in the Home directory, you can see the contents of the Home directory by using the command ls as we have studied before.

In the Home directory, there is a “Downloads” folder, then how do we get into that folder. It’s easy, you can do it by using a command like the following:

cd Downloads

Then then you will be in the “Downloads” folder, to make sure you can use the command pwd as we learned in the first part of the tutorial:

pwd

Then it will come out output like the following image which shows which directory you are in:

Viewing Current Directory After Moving Directories
Viewing Current Directory After Moving Directories

The picture above shows that we are in the “Downloads” folder in the Home directory, this means that we have successfully entered the “Downloads” folder.

How to Return to Parent Folder (One Level Up)

To return to the previous folder — which is one level from our current folder — you can do this by using the command:

cd ..

The two dots “..” in the command represent the directory one level above from the directory we are currently in.

To prove whether we have managed to move up one level or return to the parent directory, you can use the command pwd as previously:

pwd

Then the directory where you are currently will appear as shown below which indicates that we have returned to the previous folder:

Viewing Directory Contents After Returning
Viewing Directory Contents After Returning

To enter into a directory that is more than one level, for example, you are currently in the Home directory. Inside there is a “Downloads” folder which has sub folders again, namely “Pictures”.

You can enter the folder by using the following command:

cd Downloads/Pictures

Then you will go directly to the “Pictures” folder. To prove it, you can use the command pwd like the following picture:

Switching Directories More Than One Level
Switching Directories More Than One Level

This method also applies if you want to go inside sub folders with more directory structures, you can do it the same way.

Currently we are two levels below the Home directory, namely the “Downloads/Pictures” directory, almost the same as the previous method, to move up the level, you can use two dots “..”.

Since in this example we will be going two levels up, you can do this by using the following command:

cd ../..

This method also applies if you want to go up more than two directories with an unlimited number, you only need to add two more periods separated by a slash “/” as before.

In the above command, we go up two levels up to the Home directory

Actually, to move to the Home directory, no matter which directory you are in or how many levels below it, you can do it just by using a command like the following:

cd ~

This command will take you back to the Home directory. This is because the worm sign “~” is a sign that represents Home, you can return to Home by using that sign from any directory.

Enough of tutorials learning terminal on how to change directories on Linux using the CD command. In the next section, we will learn how to create a new directory using command line interfaces.

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *