An absolute path is the path from the root (/) to the destination, meaning it is the complete path.
A relative path is the path from the current working directory to the destination directory. It is always relative to the current location.
home
└── akshay
└── Desktop
├── X
│ ├── X1
│ │ ├── X11
│ │ └── X12
│ └── X2
└── Y
├── Y1
│ ├── Y11
│ └── Y12
└── Y2
mkdir -p x/x1/x1{1,2} x/x2 y/y1/y1{1,2} y/y2/F [error opening dir]
test
├── x
│ ├── x1
│ │ ├── x11
│ │ └── x12
│ └── x2
└── y
├── y1
│ ├── y11
│ └── y12
└── y2
- Absolute Path:
$ cd /home/akshay/Desktop/y/y2 $ cd ~/Desktop/y/y2
- Relative Path:
$ cd ./../../../y/y2 $ cd ../../../y/y2
- Absolute Path:
$ cd /home/akshay/Desktop/x/x1/x11 $ cd ~/Desktop/x/x1/x11
- Relative Path:
$ cd ../../x/x1/x11
- Absolute Path:
$ mkdir /home/akshay/Desktop/y/y2/y21 $ mkdir ~/Desktop/y/y2/y21 - Relative Path:
$ mkdir ../../../y/y2/y21