Server Fault is a question and answer site for system and network administrators. 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

I must be missing something obvious.

This works:

[root@host2 /]# cd /home/mysite/public_html/../logs 
[root@host2 /home/mysite/logs]# touch x

Why doesn't this?

[root@host2 /]# touch /home/mysite/public_html/../logs/x
touch: cannot touch `/home/mysite/public_html/../logs/x': No such file or directory
share|improve this question
up vote 11 down vote accepted

There's a good chance that one of the directories in /home/mysite/public_html/../logs/ is actually a symbolic link. The cd command built into most modern shells does a little magic in this case, so that cd .. takes you to the "logical" parent directory -- which takes into account how you got there.

When you try to touch /home/mysite/public_html/../logs/x, you don't get this magic.


$ ls -l /home/lars
public_html -> /var/www/lars

If I cd /home/lars/public_html I'm actually inside of /var/www/lars. So technically, ../logs does not exist (because the logs directory I want is actually in /home/lars, not in /var/www, which is the "real" parent of /var/www/lars.

share|improve this answer
Well, that's correct, and how stupid :-) Links should work all over the place. Now I guess I'm going to have to get my script to CD into the directly and then do the touch... annoying. Thanks. – Eric May 26 '12 at 1:33
@Eric you may want to mark this as answered if you feel this was the right solution. – EightBitTony May 26 '12 at 7:04

public_html is a symlink to somewhere completely different. As a shell, bash tracks symlinks in paths differently than many other programs do. Try this: cd /home/mysite/public_html then run pwd (the bash command) and /bin/pwd (the program). When touch tries to use the path, it will go to /var/www/sites/mysite/ or wherever that link points, then go up a directory from there to get to logs/... only to fail to find /var/www/sites/logs/.

share|improve this answer

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.