Occasionally in linux you will find that you have moved a file to someone's directory only to find that they can not manipulate the file. They do not have ownership of the file and are not a member of the file's group so no access to it.
To display the access permissions of a file or directory use the the command:
ls -l superfile
This displays a detailed line for the file or directory and looks like:
-rwxr-xr-x 1 romrider romrider 49211 Feb 1 12:50 superfile
This first part -rwxr-xr-x shows the access permissions on this file. Then the number of links, username, who owns it, size of the file, a time and date stamp, then the filename itself.
Now lets say you want greg to take ownership of the file. The command would be:
chown greg superfile
You should also change the group to greg so he takes complete ownership:
chgrp greg superfile
Now greg completly owns the file called "superfile" and to top it off it is in gregs group so unless you are a member of that group you don't have any permissions anymore to alter the file.
So if you are a member of the greg group, greg the user themselves, or root you can access the file.
Simple eh?
No comments:
Post a Comment