Don’t think that you knows everything about change directory (cd). There might have something you do not know. Let say I can go back to my previous location after I change directory. For example, I am currently at /var/www/html and I change directory to /home/foobar/downloads like this
And now I want to goes back to /var/www/html, usually we will do this
Instead, you can do this
cd – will brings you back to your previous directory.
Another example, there are a shortcut to goes back home directory from other directory by just type
But what if you are root and you wish to go to foobar home directory? You can do this
If you have directory symbolic link to lead you to certain directory, you may notice that when you change directory to symlink directory, the path will be symlink by default.
For example, i create a symlink directory to /mnt/fat with name fat under my home directory, when I cd fat, and check my current path with
It will shows /home/foobar/fat instead of /mnt/fat
To make it change directory to the original location, you have to specified -P
cd -P fat
Did you know all of this?