cd allows the user to change their working directory
cd eecs398
cd wk06
cd advancedhwIf the user started in home and executed these three commands, pwd would output "~/eecs398/wk06/advancedhw"
There are multiple shortcuts that can be used with cd:
"." represents your current directory
Usage:
cd ./<subdirectory>
Functionality:
Can be used to limit typing when you are "deep" in your system
For example, if you wanted to move a file from
~/eecs398/wk06/hw
down to
~/eecs398/wk06/hw/problem1
you could just go to the hw directory and use
mv <filename> ./problem1
When using cd, omitting the "." will do the same thing, i.e. you can
cd into directories in your working directory with just their names
".." represents the directory containing your current directory
Usage:
cd ..
Functionality:
Moves "up" one directory, changes your working directory to the directory
containing your current directory
This also works for longer paths, so if you are in
~/eecs398/wk06/advancedhw
and you want to go to
~/eecs398/wk06/hw
you can just use
cd ../hw
"~" represents your home directory
Usage:
cd ~
Functionality: This takes you all the way back to your home directory Allows you to accomplish multiple iterations of "cd .." in one command Omitting the ~ will do the same thing, i.e. cd without a command will default to the home directory
"-" represents the previous working directory
Usage:
cd -
Functionality:
Returns you to you previous working directory
This allows you to switch back and forth between directories
that are "far apart". If you are in
~/eecs398/wk06/advancedhw
and you use "cd ~", you will be in your home directory. If you then
use "cd -", you will be back in
~/eecs398/wk06/advancedhw