$ 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?


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

| 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
  • 1
    @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
  • 2
    @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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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