LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I give jsmith r & w permissions for myfile.txt? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-give-jsmith-r-and-w-permissions-for-myfile-txt-637867/)

lumix 04-25-2008 05:45 PM

How do I give jsmith r & w permissions for myfile.txt?
 
Chmod'ing doesn't seem to be the answer to this, since it makes no mention of individual users. So how do I let jsmith alone read and write to myfile.txt?

poet_imp 04-25-2008 06:05 PM

Let see if When jsmith was create a group by the same name was also created and jsmith is a part of that group.

grep ^jsmith /etc/passwd
jsmith:x:1000:1000:John Smith,,,:/home/jsmith:/bin/bash

grep ^jsmith /etc/group
jsmith:x:1000:

The above says that the jsmith group has the gid of 1000 and that the user jsmith's default group is 1000, so we are good.

Now look at the file: (I am going to assume that YOU are lumix)

ls -l myfile.txt
-rw------- 1 lumix lumix 6895 2008-04-18 12:24 myfile.txt

First change the group

chgrp jsmith myfile.txt

Next change the permissions

chmod g+rw myfile.txt

Look at what we have done:

ls -l myfile.txt
-rw-rw---- 1 lumix jsmith 6895 2008-04-18 12:24 myfile.txt

Both lumix and jsmith now have full access to that file. He can read it and write to it but he can not delete it or rename it. Since you own the directory the file is in you can remove or rename the file.

Is this what you were looking for?

beadyallen 04-25-2008 06:47 PM

Poet_imp's method will work, but you might want to look at ACL's. There's a quick tutorial here (it's old, FC2, but should show you how ACL's work). It saves having to create groups for every user, and in general is very powerful.


All times are GMT -5. The time now is 07:55 PM.