Hi,
I have a script which is running as root, it's supposed to store it's cache file (only modified by the script) at /var/lib/varlibfile. However the script does not seem to create the file, and my investigation led me to this:
$ sudo echo "something" >/var/lib/varlibfile
bash: /var/lib/varlibfile: Permission denied
$ sudo echo "something" >varlibfile
$ sudo cp varlibfile /var/lib/
In other words, I am able to create a file called varlibfile at /var/lib, but I'm not allowed to create it using redirection. Only file copy works. It seems very strange to me and I would like to use redirection directly to the intended file instead of creating it somewhere else and then copying it.
Some extra information:
$ ls -ld /var
drwxr-xr-x 14 root root 4096 2009-03-02 14:47 /var
$ ls -ld /var/lib
drwxr-xr-x 51 root root 4096 2009-05-16 19:25 /var/lib
$ ls -la /var/lib/ | head
total 204
drwxr-xr-x 51 root root 4096 2009-05-16 19:25 .
drwxr-xr-x 14 root root 4096 2009-03-02 14:47 ..
drwxr-xr-x 2 root root 4096 2009-03-02 14:22 acpi-support
drwxr-xr-x 2 root root 4096 2009-03-02 14:39 alsa
drwxr-xr-x 2 root root 4096 2009-05-14 14:42 apparmor
drwxr-xr-x 6 root root 4096 2009-05-14 14:42 apt
drwxr-xr-x 2 root root 4096 2008-04-04 11:56 aptitude
drwxr-xr-x 2 root root 4096 2008-07-02 12:58 aspell
drwxr-xr-x 2 avahi-autoipd avahi-autoipd 4096 2009-03-05 16:42 avahi-autoipd
Can anyone explain why this is happening? And how to solve the problem, ideally I want to write /var/lib/varfile directly without any previous creation at another location.