cd — Change the Current Directory
If there is one command that I use frequently it is cd. cd is bash shell’s built-in command. It is used to change the present working Dir to specific Dir.
$ cd — Change the current Dir to $HOME ($HOME is the default).
$ cd ~ — Same as above.
$ cd ~foo — Goto the Home Dir of foo
$ cd projects — Change the current Dir to projects
$ cd .. — Goto the parent Dir.
$ cd – — Goto the last visited Dir.
CDPATH – Easy access to frequently used Dirs. For example, I use /usr/a/dir1, /usr/b/dir2/ and /usr/c/dir3 very frequently. So I added the above dirs CDPATH like this
- Before changing to new path, cd will save the old path in the $OLDPWD evn variable.
- After changing to new path, cd will save the new path in the $PWD env variable.