While in Terminal, going back to the previous directory can be done with the classic cd ..
But there’s another way. make an alias of you choice for cd $OLDPWD, like this:
alias cdo=’cd $OLDPWD’
Now every time you’ll tipe cdo you’ll be taken to the previous directory you were in. This is very useful when you do a cd from, say, /home/username/Desktop to /usr/bin and want to quickly get back to you Desktop folder.
“cd -” 🙂
Don’t worry about the alias—it’s easier than that!
Try ‘cd -‘
Similarly, cd called with no arguments at all will take back to your home directory.
cd .. takes you to the parent directory.cd – takes you to the previous directory.
Isn’t this the same as typing
cd -
?It’s still nice to know that there is an environment variable which stores the previous directory. It might be useful for other applications.
Thanks for sharing.
The command is ‘CD -‘ That takes you to the previous directory.
And ‘CD ..’ takes you previous parent Directory