| by Arround The Web | No comments

How to go up a Directory in Linux

While working on the system, we always work on different folders to save files or other data. In Linux and Unix-Like systems, these folders are known as directories. Directories are the location where we save our data in the form of different files.

Sometimes, while working on a system, we need to switch our location and move to another directory. As all the work in the Linux system is done through commands. To move our location or change the current working directory, Linux has introduced the change directory command which is famous as the “cd” command in Linux. It is simple to use the cd command whether you want one level up directory, to navigate one level back, multiple directories navigation, or to navigate towards the root directory or home directory.

Go up a Directory in Linux Through cd Command

You need sudo privileges to run the cd command in the system.

Before getting started, keep in mind the syntax of cd command:

$ cd [directory]

 
When you start a system, your current working location is the home directory.

Let’s try how we can perform different categories to change our working directory in Linux system using cd command:

One Level-up Directory

To level up one directory using cd command, the following command would be used:

$ cd ../

 

Two level-up Directory

Similarly, to jump up two levels from the current directory or /usr directory, you can type:

$ cd ../../

 

To Return to Previous Level

If you want to return to the previous working directory, type in terminal:

$ cd -

 

Navigate to a Specific Folder

To navigate from home directory to specific folder, i-e if want to move towards download directory, the command would be:

$ cd Documents

 

Navigate to Home Directory

When you run only the “cd” command in the terminal, you will navigate to the home directory:

$ cd

 

Or another way to get back to the home directory is the “cd ..” command:

$ cd ..

 

Navigate to Root Directory

Execute the following command to change current directory to root directory:

$ cd/

 

Navigate To Directories Having Space in Name

By using the cd command, one can also change the directory having a name with space. The formula is quite simple. Use backlash (\) or double quotes around the name. For example:

$ cd “Testing Document”

 

$ cd Testing\ Document

 

Conclusion

We have seen various options like how to jump to the root directory, home directory, one level up directory, two level up directory, one level back directory and navigate towards a specific directory. This article has talked about how we can change our present directory.

Share Button

Source: linuxhint.com

Leave a Reply