Those who have made use of the cd command through a terminal application on their own operating system, have probably made use of a relative path, an absolute one or both of them. Based on my personal experience with the command line, the cd command is a Unix based one and it helps the user to navigate their filesystem through the terminal application. The cd command takes the path of the file as an argument.
For example, the following command helps the user to change their current working directory to the Desktop.
You can easily find the value of $HOME by running the following command on your own terminal application. It makes use of the echo builtin shell utility.
Once I managed to run the above command on my console application, the following output came out.
Based on my personal experience with the command line on Unix based operating systems, an absolute path starts with a slash. The slash stands for the root of the entire filesystem. As you have probably guessed, an absolute path is not relative to the current working directory. On the other hand, a relative one is.
For example, the following command makes use of a relative path.
As you can see from the above command, the relative path does not start with a slash. It is possible for it to contain forward slashes, but it does not start with one. The directory Test is a subdirectory within my Desktop.
As we explained through this short blog post, the main difference between an absolute and a relative path is that the absolute one starts with a forward slash, a symbol which stands for the root directory when defined in a file path. Practically both absolute and relative paths can be handy to those who make use of the command line utilities.