Linux permissions: Difference between revisions

From Bitpost wiki
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Managing a shared folder with a linux group ===
=== Managing a shared folder with a linux group ===
* create a group
sudo groupadd mygroup # create a group
  sudo groupadd mygroup
  sudo usermod -a -G mygroup $USER # add yourself
* add yourself (and others)
  sudo usermod -a -G mygroup someone # (and others)
  sudo usermod -a -G mygroup myuser
mkdir myshare && chmod ug+ws myshare # set up a folder for sharing - you want g+w(rite) and g+s(ticky)
* set up a folder for sharing - you want g+w and g+s
mkdir myshare && chmod g+ws myshare


If you need to share an existing folder, you need to do g+w and also retroactively update g+s on all the directories manually with this stupid hack (becuase -R doesn't work, stupid linux bullshit):
If you need to share an existing folder, you need to do +w and also retroactively update +s on all the directories manually with this stupid hack (because -R doesn't work, stupid linux bullshit):
  sudo chmod -R g+w myshare
  chmod ug+ws existingshare
  find myshare -type d -exec chmod g+s '{}' \;
  find existingshare -type d -exec chmod ug+s {} \;
find existingshare -type f -exec chmod ug+w {} \;
 
If this is a git repo, it should be configured to behave:
git config core.sharedRepository group


=== Restricting a user to a specific folder ===
=== Restricting a user to a specific folder ===

Latest revision as of 14:21, 24 June 2022

Managing a shared folder with a linux group

sudo groupadd mygroup # create a group
sudo usermod -a -G mygroup $USER # add yourself
sudo usermod -a -G mygroup someone # (and others)
mkdir myshare && chmod ug+ws myshare # set up a folder for sharing - you want g+w(rite) and g+s(ticky)

If you need to share an existing folder, you need to do +w and also retroactively update +s on all the directories manually with this stupid hack (because -R doesn't work, stupid linux bullshit):

chmod ug+ws existingshare
find existingshare -type d -exec chmod ug+s {} \;
find existingshare -type f -exec chmod ug+w {} \;

If this is a git repo, it should be configured to behave:

git config core.sharedRepository group

Restricting a user to a specific folder

I have found that for several folders on my server I do not have the w+x bit set for folders:

drwxrwxr-- 12 m m 4.0K Feb  3  2017 .

This was killing me, as I tried to set user-specific permissions on symlinks to subfolders deep within the top level folder. They would fail because the user could not cd to the folder due to the missing +x. You have to make sure the WHOLE F'IN FOLDER CHAIN HAS g+x ON IT in order for a specific user to be able to cd to it.