OpenSUSE Linux Rants

OpenSUSE Linux Tips, tricks, how-tos, opinions, and news

My Resume  -  My LinkedIn Profile

July 11, 2007

change… and back again

by @ 7:11 am. Filed under General Linux, SUSE Tips & Tricks

One command that I use often is “cd.” That’s great for getting to specific directories. A couple of quick tips:

First, you can use it by itself to return to your home directory. If you username is “joe”, and at a command prompt you run “cd” by itself, you are taken to “/home/joe/”. That’s pretty cool.

Second, if you run it with a “-” (dash), it takes you back one in your “present working directory” history. So if I am at “/home/scott” and then I type “cd ..” and hit ENTER, I will be at “/home/”. If I type “cd -” and hit ENTER, I am taken back to where I just was, which is “/home/scott”. Run it again, and I am taken back to where I just was, which is “/home/”.

This is really great if you have to keep switching back and forth between the same two directories in the project you’re working on.

4 Responses to “change… and back again”

  1. Béranger Says:

    Scott, “cd -” is so fundamentally elementary 🙂 that it is in each and every “Linux 101” book!

    But it’s very useful indeed!

  2. Scott Morris Says:

    Yeah, I love it. Linux is just full of slick little things like that where you just say, “Man, the guy who wrote this was really thinking!” every time you use them. 🙂 Thanks for stopping by.

  3. Ernesto Says:

    Ah, those tiny little things that help you make it better through the day!

    Thanks for the tip! You wouldn’t believe it Béranger, but I’ve been actively using Linux and the CLI for several years now, and today I found out about “cd -” thanks to Scott. Guess I never read a “Linux 101” book, seriously.

    So, the tip is wonderfully in line for those of us still in the shadows. Keep posting useful stuff Scott!

  4. Sascha Says:

    great tip, that’s save some typing!

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:


SUSE Resources

search blog:


March 2022
« Feb    

62 queries. 0.943 seconds