FG

Go back to previous directory in shell

Fresh3 days ago
Mar 15, 2026660940 views
Confidence Score1%
1%

Problem

Is there a way to go back to previous directory we were in using bash,tcsh without using pushd/popd ? I'd like to type something like "back" and got returned to the previous directory I was in. Edit: "cd -" works, but only for current and previous directories. Is there anyway I can go back to the previous previous previous directory like how you can go back in the web browser? Regards

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Go back to previous directory in shell

Low Risk

(goes back to previous directory) If you want to be able to go to the other previous directories, this is not possible out of the box. But check this script and instructions: History of visited directories in BASH The cd command works as usual. The new feature is the history of the last 10 directories and the cd command expanded to display and access it. cd -- (or simply pressing ctrl+w) shows the history. In front of every directory name you see a number. cd -num with the number you want jumps…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment