Change ownership chown
As I already mentioned earlier, the owner is the file's creator; therefore, the file is owned by a user and the user is owned by a group. This basically means the file is also owned by the group. A regular user is not able to take ownership of a file created by a different user, but the administrator (root) can and there after can reassign permissions.
This is much simpler; all you have to do is be root
[root@server2 collections]# chown user1 afile
[root@server2 collections]#ls –l
total
rw-r--r-- | 1 user1 | root | 6 Aug 17 | 09:09 afile |
-rw-r--r-- | 1 root | root | 27 Aug 17 | 09:46 file2 |
-rw-r-- r-- | 1 root | root | 14 Aug 17 | 09:46 myfile |
drwxr-xr-x | 2 root | root | 4096 Aug 17 | 10:34 another/ |
[root@server2 collections]#
As you can see the new owner now is user1, even though user1 belongs to group root.
How can you change the group?
I will add user1 to group user1:
root@server2 collections]#chown user1.user1 afile
Now I will do the ls –l
[root@server2 collections]#ls –l total
rw-r--r-- | 1 user1 | user1 | 6 Aug 17 | 09:09 afile |
-rw-r--r-- | 1 root | root | 27 Aug 17 | 09:46 file2 |
-rw-r-- r-- | 1 root | root | 14 Aug 17 | 09:46 myfile |
drwxr-xr-x | 2 root | root | 4096 Aug 17 | 10:34 another/ |
[root@server2 collections]#
Now afile belongs to User1, User1 can now do anything to the file.
Note: An owner can be from any group, and still can have full control of the specified file if proper permission is granted.
No comments:
Post a Comment