Forrest logo
back to the cd tool

cd:tldr:fd1a8

cd: Go to the previously chosen directory.
$ cd -
try on your machine

The "cd -" command is a shell command used to switch to the previous directory that you were in.

Here's how it works:

  1. When you are in a directory, let's say "directory A," and you want to switch to another directory, let's say "directory B," you can use the "cd" command followed by the directory name, like this: "cd directory B."

  2. Now, if you want to go back to "directory A," you can simply type "cd -" instead of explicitly writing out the path to "directory A." The "-" symbol tells the shell to go to the previous directory you were in, which in this case is "directory A."

In summary, "cd -" allows you to quickly switch to the previous directory without typing out the full path.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • how do i change to the last directory?
back to the cd tool