Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

who can do chmod? 1

Status
Not open for further replies.

dswoop

Programmer
Mar 3, 2003
1
0
0
CA
This must be easy but I'm new to this

Is it that only the superuser or owner can do chmod on a file? If not, who else can do chmod?

What happens if I have a hardlink or softlink to a file but I'm not the owner, can I still do a chmod?

many thanks,

~d
 
According to the manual (verbatim):
"Only the owner of the file or the root user can change the mode of a file."

HTH

Dickie Bird (:)-)))
 
Assuming that you have read permissions to the file and write permissions to the directory then you can take ownership of a file...

mv $FILE $FILE.tmp
cp $FILE.tmp $FILE
rm $FILE.tmp

...so you can now chmod it!
 
The ability to chmod a file is governed by the current users ability to WRITE the file.

The ability to WRITE a file is determined by:

1. ownership
2. file permissions

If the current user OWNS the file, then the file permissions can be modified, and so the permissions are irrelevant.

If the current user does NOT own the file then the ability to WRITE a file are governed solely by the permissions on the file, and the current users role. If the current user is a member of the same unix group as the group owner of the file, then the current users role is GROUP. Otherwise it is WORLD.

File permissions are set in three groups of Read/Write/Execute permissions:

OWNER GROUP WORLD
rwx rwx rwx

These can be examined with the 'ls -l' command:

%ls -l
-rw-rw-rw- 1 user1 group1 0 Mar 4 11:03 file1
-rw-rw-r-- 1 user1 group1 0 Mar 4 11:03 file2
-rw-r--r-- 1 user1 group1 0 Mar 4 11:03 file3

In the example above, the user 'user1' can WRITE and therefore chmod any of the files. Any member of 'group1' can WRITE and therefore chmod file1 and file2. Any user can WRITE and therefore chmod only file1.

Christian
 

roylec,
this is NOT true. If it is, please tell me what system you use.
I just tested it on AIX and as far as I remember, it's the same on Solaris. ONLY the owner of the file (and root) can change the permissions.

Cheers Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 
Henrik's correct. I made the same mistake telling someone about chown recently too! Annihilannic.
 
Absolutely right Morsing (and Annie) - my post is mis-leading, it must have been a bad day for me.

C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top