Bash cd - Change Directory
Using the cd Command
The cd command is used to change the current working directory in the terminal.
Basic Usage
To change to a specific directory, use cd directory_name:
Special Directories
These are not options, but special directory names you can give cd as an argument:
cd ..: Move up one directory levelcd ~: Change to the home directorycd -: Switch to the previous directorycd /: Change to the root directory
Move Up One Directory Level (cd ..)
The cd .. command lets you go to the folder above your current one.
It's useful when you need to go to the parent folder.
Change to Home Directory (cd ~)
The cd ~ command takes you to your home directory, which is the default directory for your user account.
This is useful when you need to return to your starting point after navigating through various directories.
Switch to Previous Directory (cd -)
The cd - command switches your working directory to the previous one you were in.
This is useful for toggling between two directories without needing to type their full paths repeatedly.
Change to Root Directory (cd /)
The cd / command takes you to the root directory of the file system.
This is useful when you need to access system-wide files or directories.
Combining Options
The cd command itself does not support combining options, but you can use it in conjunction with other commands to enhance navigation efficiency.
For example, using cd with ls can quickly show you the contents of a directory you navigate to:
Example: Change and List
cd my_directory && ls
images my_file.txt myfolder report.csv