LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1070|回复: 6

分区针对不同用户权限

[复制链接]
发表于 2007-10-17 21:10:21 | 显示全部楼层 |阅读模式
怎么使得分区对于不同的普通用户权限
比如一个用户可以读,一个用户可以读写?可以用fstab实现马?
分区为xfs,fat

还有一个问题,创建桌面启动器时,怎么设置启动目录,好像没看见启动目录这一行?
发表于 2007-10-17 21:13:29 | 显示全部楼层
umask,,还有其他的几个mask好像是管这个的,具体的你搜搜看把
回复 支持 反对

使用道具 举报

发表于 2007-10-17 21:17:40 | 显示全部楼层
umask
From Wikipedia, the free encyclopedia


umask (abbreviated from user file creation mode mask) is a function in POSIX environments which affects the default file system mode for newly created files and directories of the current process. The permissions of a file created under a given umask value are calculated using the following bitwise operation (note that umasks are generally specified in octal)

    bitwise AND of the unary complement of the argument (using bitwise NOT) and the full access mode.

The full access mode is 666 in the case of files, and 777 in the case of directories. Most Unix shells provide a umask command that affects all child processes executed in this shell.

[edit]Examples

Assuming the umask has the value 174, any new file will be created with the permissions 602 and any new directory will have permissions 603 because:

6668 AND NOT(1748) = 6028

while

7778 AND NOT(1748) = 6038

7778 = (111 111 111)2
1748 = (001 111 100)2
NOT(001 111 100)2 = (110 000 011)2
(111 111 111)2 AND (110 000 011)2 = (110 000 011)2
7778           NOT (174)8          (603)8


Doing this in bash:

$ umask 0174
$ mkdir foo
$ touch bar
$ ls -l
drw-----wx 2 dave dave 512 Sep  1 20:59 foo
-rw-----w- 1 dave dave   0 Sep  1 20:59 bar

[edit]
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-18 19:31:25 | 显示全部楼层
umask可以设置权限,但我要针对不同的用户?uid,gid需要怎么配合?
回复 支持 反对

使用道具 举报

发表于 2007-10-19 14:56:19 | 显示全部楼层
Linux / Unix 的文件访问权限好像不能似 MS Windows 那样可以针对每一个用户写权限. 而只能把用户分成三类, 所有者/所有组/其它.

比如你想只允许用户 jefferson 对  /foo 目录有写权限, 其它用户有读权限, 那么你可以

chown jefferson:jefferson foo
chmod 022 foo

然后 ls -l 看到的应该是这样:
drwxr-xr-x  2 jefferson jefferson


可能你还想让用户 bufferfly 也有写的权限, 那么就得改变 所有组 及权限.

chown jefferson:supergroup foo
chmod 002 foo

然后你得把 bufferfly 加到组 supergroup 里面去.

最后 ls -l 看到的是:
drwxrwxr-x  2 jefferson supergroup
回复 支持 反对

使用道具 举报

发表于 2007-10-19 16:01:36 | 显示全部楼层
acl可以。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-19 18:19:07 | 显示全部楼层
Post by bufferfly
Linux / Unix 的文件访问权限好像不能似 MS Windows 那样可以针对每一个用户写权限. 而只能把用户分成三类, 所有者/所有组/其它.

比如你想只允许用户 jefferson 对  /foo 目录有写权限, 其它用户有读权限, 那么你可以

chown jefferson:jefferson foo
chmod 022 foo

然后 ls -l 看到的应该是这样:
drwxr-xr-x  2 jefferson jefferson


可能你还想让用户 bufferfly 也有写的权限, 那么就得改变 所有组 及权限.

chown jefferson:supergroup foo
chmod 002 foo

然后你得把 bufferfly 加到组 supergroup 里面去.

最后 ls -l 看到的是:
drwxrwxr-x  2 jefferson supergroup

谢谢,回去试一下,ths
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表