Definition:
When you are in the terminal and want to provide the full location, you give the absolute path.
It always starts from /
(root).
After /
(root), you must write the full address so that it reaches the destination location.
This path can reach the destination in two ways:
- Directly – by writing the complete address in one go.
- Recursively – by moving step by step through folders and subfolders.
Syntax:
cd /full/path/to/folder
Example 1:
In the terminal, if you are in the Documents
folder and want to open the
Projects
folder, then type this command:
cd /home/user/Documents/Projects
Directory Structure Diagram:
/ └── home └── user └── Documents └── Projects
Example 2:
When you are in the Projects
directory and you want to open a file kept in another directory
(Desktop → Images → photo.png
), then follow these steps:
-
Firstly, check the present working directory:
pwd
Output:
/home/user/Documents/Projects
-
Now change the directory to the
Desktop/Images
folder:cd /home/user/Desktop/Images
-
Check the files inside the Images folder to confirm:
ls
Output:
photo.png otherfile.txt
-
Finally, open the file:
xdg-open photo.png
Directory Structure Diagram:
/ └── home └── user ├── Documents │ └── Projects └── Desktop └── Images ├── photo.png └── otherfile.txt