Thursday, May 2, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 13220  / 2 Years ago, thu, june 9, 2022, 6:00:58

I want every user to have full permissions over a single directory(and all the contents). Is this possible, and how? Thanks.


More From » command-line

 Answers
7

You can get what you want to with adding users in particular group and then applying full permission to that group.



(echo $USER & echo $LOGNAME is helpful to get username and logname)



Example:



If/Let:



dir1 is directory to which you want to apply full permission to user,

user1 is user to which you want to give full permission,

group1 is existing or to be create for giving full permission.



Then following command-line information can help you:




  1. group1 can be created using following command:



    sudo addgroup group1

  2. user1 can be added to group1 using following command:



    sudo adduser pandya group1

  3. Now permissions can be applied using following commands:



    sudo chown :group1 -R dir1
    sudo chmod g+rwx group1



Explanation:




  • sudo chown :group1 -R dir1 will apply group1 to dir1 recursively by -R (to all sub directories and files)

  • sudo chmod g+rwx group1 will apply read+write+execution permission to group1

  • As user1 is in group1 so-that now user1 has full permission via group1 for dir1 recursively!



Verification:



$ ls -ld dir1
drwxrwxr-x 3 pandya group1 4096 Aug 3 12:11 example


where drwxrwxr-x indicates d for directory 1st rwx for owner(u=pandya) permission 2nd rwx for group(g=group1) permission and r-x for other(o) permission in ugo manner.


[#23856] Thursday, June 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calcur

Total Points: 189
Total Questions: 80
Total Answers: 95

Location: Burkina Faso
Member since Thu, Dec 15, 2022
1 Year ago
;