UNIX的文件访问控制——chmod

来源:互联网 发布:淘宝ar红包 编辑:程序博客网 时间:2024/06/08 02:33

先看下面这张PPT


我们对文件的访问者一共分成了3类:文件主(文件的创建者)、文件主的同组用户、其他用户

我们对文件的操作权限的识别分成了3类:读(r)、写(w)、执行(x)

      chmod 是一条在Unix系统中用于控制用户对文件的权限的命令

这里的711的意思是:

7对应文件主:7用二进制表示是111,表示可以读、写、执行

1对应文件主的同组用户:1用二进制表示是001,表示不能读写,只能执行

1对应其他用户:1用二进制表示是001,表示不能读写,只能执行

所以这里的711的意思是:文件主可以读、写、执行文件,但同组用户和其他用户只能执行。

同理,我们来分析一下755的含义:

7——111,5——101,表示:文件主可以读、写、执行文件,但同组用户和其他用户只能读、执行。


例题:

The chmod command (命令) is used to change the permission (许可) of file in Linux. To use it, you specify the desired permission setting and the file or files that you wish to modify. The permission settings are usually a series of bits. Which of the following bits present thatthe file’s owner may read, write, and execute the file, while all others mayonly read the file? .

  755
  744
  644
  611
解答:B

这里的意思是:文件主可以读、写、执行,但是同组用户和其他用户只能读,所以第一位是7,第二位和第三位是100,也就是4