[英]Handle permissions with groups in linux
I can't understand how exactly this works in Linux. 我无法理解它在Linux中是如何工作的。
For example, I want only users in some group have access to execute some file (I hope this is possible without visudo
). 例如,我希望只有某些组中的用户可以访问执行某些文件(我希望没有
visudo
这是可能的)。
I create a system user and system group like: 我创建了一个系统用户和系统组,如:
useradd -K UID_MIN=100 -K UID_MAX=499 -K GID_MIN=100 -K GID_MAX=499 -p \* -s /sbin/nologin -c "testusr daemon,,," -d "/var/testusr" testusr
I add my current user user
to the group testusr
(may be not cross platform): 我将当前用户
user
添加到组testusr
(可能不是跨平台):
adduser user testusr
I create some test shell file and set permissions: 我创建了一些测试shell文件并设置了权限:
touch test.sh
chmod ug+x test.sh
sudo chown testusr:testusr test.sh
But I still can't start test.sh as user
: 但我还是无法以
user
身份启动test.sh:
./test.sh
-> Error
Now I look for some system groups like cdrom
to check how they work. 现在我寻找像
cdrom
这样的系统组来检查它们是如何工作的。 My user
is in cdrom
group and can use the cd rom on my computer: 我的
user
在cdrom
组中,可以在我的电脑上使用光盘:
$ ls -al /dev/cdrom
lrwxrwxrwx 1 root root 3 апр. 17 12:55 /dev/cdrom -> sr0
$ ls -al /dev/sr0
brw-rw----+ 1 root cdrom 11, 0 апр. 17 12:55 /dev/sr0
Addition: 加成:
./test.sh
command starts to work as I want after system reboot. 系统重启后,./
./test.sh
命令开始按照我的意愿运行。 Strange... 奇怪...
I'm on Ubuntu Studio 15.10 我在Ubuntu Studio 15.10上
只有在重新登录时才会反映组更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.