Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


$ pwd
$ ls -l
total 3604
lrwxrwxrwx 1 user user  19 Nov 27 12:11 pages -> /var/www/pages/

$ cd pages
$ pwd
$ readlink -f .

$ cd ..
$ readlink -f .

When I'm in /var/www/pages I would like to go up to /var/www however running cd .. brings me to /home/user. Obviously this is due to having gotten to /var/www/pages via a symlink. How can I cd up one directory when I'm in a symlink?

share|improve this question
up vote 10 down vote accepted

cd -P ..
You should read more preciscly manual ;-)

share|improve this answer
Thanks! Actually, I tried to read the fine manual however No manual entry for cd, and info cd gives irrelevant information. This is on two Ubuntu systems. – dotancohen Nov 27 '13 at 12:55
cd is a build in shell command so so man is not exciting, but man cd give good result in google ;) – Kiwy Nov 27 '13 at 12:56
@dotancohen cp --help generally gives short info compared to the main page (or in this case, all the info since it doesn't have a man page) – Izkata Nov 27 '13 at 14:59
@dotancohen Because cd is built in to the shell, you can find the documentation for it inside the shell manual (man bash). Scroll down to the "SHELL BUILTIN COMMANDS" section. Also a general search for cd in that man page is illuminating; it will teach you about $OLDPWD, $CDPATH, and some other fun stuff. – dg99 Nov 27 '13 at 16:32
alias back=cd "$OLDPWD" – Rob Nov 27 '13 at 17:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.