This article will help you to know that how you can change the Directory in Ubuntu. For an instance, you are required to change the directory to access the folders & files stored in that particular location, then you have to use “cd” command for it.
The “cd” command can be used in numerous ways which will surely depend upon your requirement. To access cd command i.e change directory command, follow the steps illustrated below:
Steps to Change the Directory in Ubuntu
Step 1: To change the directory, firstly you must know where you are, and for that you need to type “pwd”, this will show the working directory name.
I got the result as “/home/ubuntu14” as shown in the image below.
Step 2: Now I want to go to the Desktop, so that I can easily access the folders available under my Desktop.
Type “cd Desktop” and press enter.
Step 3: Here, you can see the directory is changed to the Desktop.
Step 4: If any time, you need to return to the home directory, type “cd ..”
Step 5: By using the above command you are redirected to the home path as shown in the figure below.
Step 6: If want to locate a particular path, then you have to mention the full path.
For an example: “cd /home/ubuntu14/Desktop” where ubuntu14 is the username.
Step 7: You can see the output of the above command by just pressing enter.
Step 8: Suppose you are required to go back to the parent directory, no matter where you currently are. Type the “cd ..” command and press enter, look at the o/p in the figure corresponding to the command.
If your choice changes suddenly and you need to access any folder that resides in the Desktop, then irrespective of the current location type “cd ~/Desktop”.
Step 9: Now you are at the “Desktop” location in the terminal. Here, you can access the files stored in this particular location.
NOTE: Some of the other options used with “cd” command are:
- “cd -“ used to return to the previous directory
- “cd /” is used to go to the Root directory