Bash Quick Start Guide
上QQ阅读APP看书,第一时间看更新

The cd command

Where pwd or $PWD gets the current working directory for the shell, the cd Bash builtin command sets the working directory:

$ pwd
/home/bashuser
$ cd /tmp
$ pwd
/tmp

When issued with no arguments, the cd command defaults to the current user's home directory. Again, it does this by reading the $HOME environment variable first, if it can:

$ cd
$ pwd
/home/bashuser

You can change to the parent of the current directory with the .. name:

$ pwd
/home/bashuser
$ cd ..
$ pwd
/home