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
There's a good chance that one of the directories in
/home/mysite/public_html/../logs/
is actually a symbolic link. Thecd
command built into most modern shells does a little magic in this case, so thatcd ..
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.Consider:
If I
cd /home/lars/public_html
I'm actually inside of/var/www/lars
. So technically,../logs
does not exist (because thelogs
directory I want is actually in/home/lars
, not in/var/www
, which is the "real" parent of/var/www/lars
.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 runpwd
(the bash command) and/bin/pwd
(the program). Whentouch
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 tologs/
... only to fail to find/var/www/sites/logs/
.