`cd -`

`cd -`
Image credit: Unknown. Please contact us if you are the owner.

In Linux, the command cd - is used to switch to the previous directory you were in. It acts as a shortcut to quickly toggle between two directories.

Here’s a breakdown of its usage:

Use case:

  1. Suppose you are in /home/user/docs and you change to /etc:
$ cd /etc/


  1. To go back to /home/user/docs, you would use:
$ cd -

After executing cd -, your cwd "Current Working Directory" would now be /home/user again.



Benefits:

  • Quick Navigation: Useful when you need to switch between two directories repeatedly.
  • Avoid Retyping Paths: Saves time by not having to type out full directory paths each time you switch.



This command is especially useful for tasks that require frequent switching between directories or quick access to files located in different places.
And remember, in the world of tech, always choose your commands wisely –

Keep Us Caffeinated  ⦿ ⦿