title: Bash cd
Bash command: cd
cd – Change Directory
It is used to change the current working directory.
Change Directory to the path specified, for example
There are a few really helpful arguments to help with this:
.refers to the current directory, such as
..can be used to move up one folder, use
cd .., and can be combined to move up multiple levels
-takes you back to the previous directory you were working on. For example,
/is the root of your system to reach core folders, such as
~is the home directory, usually the path
/users/username. Move back to folders referenced relative to this path by including it at the start of your path, for example
-can be used to move to the previous directory. For example, you are in
/A, then cd to
cd -and you are back to
~[number]will cd to that entry from the output of
dirsdirectories can be pushed or popped to the ‘dirs’ stack using
- Typing only
cdwill move to the home directory works same as
cd $HOMEwill also move to the home directory.
- Typing ‘pwd’ will show you which directory you are currently working in.
Change directory to
cd command is the daily workhorse for navigating through your path, but closely related are the
dirs commands, which maintain a stack of your directory movements and allow you to more quickly navigate through this stack.