Results 1 to 6 of 6
Thread: Changing Ownership of a File
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Jul 2010
Changing Ownership of a File
By using the chown, chgrp commands?
Issue these commands for more help, in a terminal window.
The chown utility allows you to change the owner of a file. Run the command "man chown" for details.
Note that as a general rule, you shouldn't be creating files in another user's home directory. It is fairly common for a user's home directory to be unwritable for other users in any case. You should treat a user's home directory as their own private domain.
- Join Date
- Jul 2010
Thanks for your suggestion.
I had tried using chown to change the permission but got "Operation not permitted " error. Infact "redhatuser02" user's secondary group is "redhatuser01" and the file created there has got execute permission set to it. Am i missing here anything? or is it really possible ?
(I understand that its not a good practice to create a file under some other user's home directory and th
is is not part of a production code and i am trying to test a concept.)
Please read these:
man chown man chgrp man chmod man usermod man umask
you should under no circumstances allow one user to write to another users home directory. a common place where to put variable data that can be shared is /var.
i.e. create a group "sharegroup", add both users to that "sharegroup" using usermod, create a directory under var with read/write permissions for the group "sharegroup" (g+rw) and let both users access those files. you could even make up a symbolic link to those files in their home directory or make a hardlink if the files are shared through ftp which do not follow symbolic links. note: you would also have to change the "umask" of both users in order to create files with the g+rw permissions by default. otherwise you would need a cronjob to do that job for you OR make sure the files that are being written are "chmod"-ed to g+rw after creation (if you have a script that is being run, it is just one more line).
if you need more fancy things google this:
ACL (access control list)
this little thing allows you to set access permissions on a file/directory for multiple users/groups. it was invented cause certain situations like this here are quite complicated to handle only with the categories user, group and other.
this said, you would be able to do everything without the need of a "sharegroup", but with the drawback that things are no longer obvious and easy understandable for others that ask themselves "why is this user writing to that folder and how does it work?".
Last edited by Kloschüssel; 08-04-2010 at 06:26 AM.