Which command lets you change back to the last working directory?
-
cd -
-
cd ~
-
cd ..
-
cd .
The command 'cd -' (cd dash) switches to the previous working directory. It toggles between the current directory and the last directory you were in. 'cd ~' goes to your home directory, 'cd ..' goes up one level to the parent directory, and 'cd .' stays in the current directory (the dot refers to the current directory itself).
cd - is the shell shortcut that switches back to the previous working directory (the one you were in before your last cd), and it also prints that path. cd ~ always goes to your home directory, cd .. moves up one level to the parent directory, and cd . stays in the current directory (a no-op) — none of these reference the 'last' directory you were in, only cd - does.