The cd - command in Linux is used to switch to the previous directory you were in. When you execute this command, it takes you back to the last directory you navigated from, allowing you to quickly toggle between two directories.
Example:
- Suppose you are in
/home/user/documents. - You then change to
/var/logusingcd /var/log. - If you now run
cd -, you will return to/home/user/documents.
This command is particularly useful for quickly navigating back and forth between two locations in the file system.
