What is the 'cd -' command?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 02 2025
0145

The command cd - in Bash is used to switch back to the previous directory you were in. It acts as a toggle between your current directory and the last one you navigated from.

Example:

  1. Suppose you are in /home/user/documents.
  2. You then change to /home/user/downloads using:
    cd /home/user/downloads
  3. If you run:
    cd -
    You will return to /home/user/documents.

Usage:

  • This command is helpful for quickly switching back and forth between two directories without needing to type their full paths.

If you have more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!