Go Back to the Previous Directory via Command Line
It’s easy to accidentally change directories to something you weren’t intending to (say, accidentally hitting cd and returning home, thus losing your place in a complicated directory structure seep in the file system somewhere), but thankfully there’s a command that will immediately take you back to the previous directory, regardless of what it was. The jump-back to prior directory command is a simple variation on ‘cd’ followed by a single dash (the minus symbol), the syntax looks like so: