Hello,
I need to know if there is something I am missing about file permission as I believe I am seeing some strange stuff on my system. I have a directory as follows:
drwxrwxrwx 7 root root 4096 Mar 10 13:35 temp
In this directory I have a file:
-rw-r--r-- 1 root root 137 Oct 30 02:16 208-109-248-33test
As a normal user should I be able to rename this file? I believe that only root should be able to modify this file but as a normal user I am able to rename it without elevated privileges as so:
temp $ mv 208-109-248-33test 208-109-248-33-mv
[Sat Mar 10 13:41:05] /temp
temp $ lt 208* -rw-r--r-- 1 root root 137 Oct 30 02:16 208-109-248-33-mv
How is this possible? If it is possible what am I missing or not understanding? Thnx.
On Saturday, March 10, 2012 01:45:19 PM Robert Spangler wrote:
drwxrwxrwx 7 root root 4096 Mar 10 13:35 temp
...
temp $ lt 208* -rw-r--r-- 1 root root 137 Oct 30 02:16 208-109-248-33-mv
How is this possible? If it is possible what am I missing or not understanding? Thnx.
You have write permissions to the directory; renaming a file needs write on the directory, not on the file.
On Sat, Mar 10, 2012 at 01:45:19PM -0500, Robert Spangler wrote:
Hello,
I need to know if there is something I am missing about file permission as I believe I am seeing some strange stuff on my system. I have a directory as follows:
drwxrwxrwx 7 root root 4096 Mar 10 13:35 temp
In this directory I have a file:
-rw-r--r-- 1 root root 137 Oct 30 02:16 208-109-248-33test
As a normal user should I be able to rename this file? I believe that only root should be able to modify this file but as a normal user I am able to rename it without elevated privileges as so:
temp $ mv 208-109-248-33test 208-109-248-33-mv
[Sat Mar 10 13:41:05] /temp
temp $ lt 208* -rw-r--r-- 1 root root 137 Oct 30 02:16 208-109-248-33-mv
How is this possible? If it is possible what am I missing or not understanding? Thnx.
As Mr Owen remarks, nothing is broken. To get the mode ("permissions") semantics that you might be expecting, set the "sticky bit" of the directory.
<root> # chmod +t temp
Then the mode will appear as "drwxrwxrwt" ( 1777 in octal).
Notice that this is the same as the mode for /tmp.
"In Unix, everything is a file." Directories are files, too.
Dave
On Saturday 10 March 2012 13:45, the following was written:
Thnx everyone. I was under the impression that even though you had access to the directory you still could not touch a file that you were not part of the owner or group unless the bits were set.
On Sun, Mar 11, 2012 at 9:48 AM, Robert Spangler mlists@zoominternet.net wrote:
On Saturday 10 March 2012 13:45, the following was written:
Thnx everyone. I was under the impression that even though you had access to the directory you still could not touch a file that you were not part of the owner or group unless the bits were set.
You can't affect the contents of the file, but the name is a directory entry which is a separate thing. Note that with hard links you can have multiple names that might be in different directories pointing to the same contents.