2

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.

  • The "others" set is implicitly defined as users that do not own the file and are not in the group that owns the file. – Ignacio Vazquez-Abrams Nov 2 '17 at 14:22
3

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

  • 1
    Chmod controls what can be done with a file, chown controls who can do it – ivanivan Nov 5 '17 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.