How are chown and chmod command different in the given operation?
You're mixing two different things.
- chown - changes ownership of files/dirs. Ie. owner of the file/dir changes to the specified one, but it doesn't modify permissions.
Let's explain your command:
chown robo:wwwrobo /home/souvik/public_html
With this command you said that new owner of the dir /home/souvik/public_html is now user 'robo' and new group is 'wwwrobo'. You haven't modified permissions!
- chmod - modifies permissions of the file/dir, doesn't change ownership!
Let's explain your command:
chmod 755 /home/souvik/public_html
The permissions of directory /home/souvik/public_html changed to rwx for owner (robo), r-x for group (wwwrobo) and r-x for others (all other users on the system).
rwx means full access (read/write/enter in directory context; read/write/execute in file context) r-x means that the user/group is only allowed to read/enter(execute) the file/dir, but can't write there
See full description:
https://www.linux.com/learn/understanding-linux-file-permissions
Related videos on Youtube
Souvik Ray
Updated on September 18, 2022Comments
-
Souvik Ray almost 2 years
If I change the ownership of the contents of a file and further set permissions to the content of the file, how exactly are both the operations different?
For example, if I change the ownership of the files in a directory (public_html) to only owner and group.
chown robo:wwwrobo /home/souvik/public_html
And then if I change the file permissions of the contents inside public_html such that
chmod 755 /home/souvik/public_html
In the first command, for the 'others' clearly I haven't given any ownership to the files and in the second command I am giving read and execute permission to others (chmod 755). So what will exactly happen now? If I haven't given any ownership to 'others', what's the point of giving file permission of 5 to 'others'? They don't own the file anyway.
I am asking this because I saw these two set of commands being used one after the other in an example.
-
Ignacio Vazquez-Abrams over 6 yearsThe "others" set is implicitly defined as users that do not own the file and are not in the group that owns the file.
-
-
ivanivan over 6 yearsChmod controls what can be done with a file, chown controls who can do it