some tips of change directory

August 30th, 2006 mysurface Posted in cd, Common, ln, pwd | Hits: 30186 | 1 Comment »

Don’t think that you knows everything about change directory (cd). There might have something you do not know. Let say I can go back to my previous location after I change directory. For example, I am currently at /var/www/html and I change directory to /home/foobar/downloads like this

cd /home/foobar/downloads

And now I want to goes back to /var/www/html, usually we will do this

cd /var/www/html

Instead, you can do this

cd -

cd – will brings you back to your previous directory.

Another example, there are a shortcut to goes back home directory from other directory by just type

cd

But what if you are root and you wish to go to foobar home directory? You can do this

cd ~foobar

If you have directory symbolic link to lead you to certain directory, you may notice that when you change directory to symlink directory, the path will be symlink by default.

For example, i create a symlink directory to /mnt/fat with name fat under my home directory, when I cd fat, and check my current path with

pwd

It will shows /home/foobar/fat instead of /mnt/fat

To make it change directory to the original location, you have to specified -P

cd -P fat

Did you know all of this?

One Response to “some tips of change directory”

  1. Thanks bud

Leave a Reply