5.3 管理文件权限和拥有者

By admin, 31 一月, 2019

1. 文件权限

$ ls -l

drwx------  28 root root      4096 Jun 10 16:13 ./

drwxr-xr-x  22 root root      4096 Apr  1 23:04 ../

-rw-r--r--   1 root root      1682 Dec 21 10:18 zscan.pl

ls -l (一般可以简写成ll)可以查看目录里文件的详细信息。第一组是文件的权限,第一个字母如果是d表示目录。.是当前目录,..是上一级目录。第一组信息第2-4各字母表示文件所有者所具有的权限,第5-7各字母是文件所属组具有的权限,第8-10各字母是所有人具有的权限。r表示可读(值为4),w表示可写(值为2),x表示可执行(值为1)。对于目录来说,可执行表示可以进入目录。

我们可以用下面命令给所有用户添加可读性权限:

$ chmod a+r foo

也可以用以下命令给文件所有者添加可读、可写权限,而其它人什么权限都没有:

$chmod 600 foo

这个命令的600是什么意思呢?可读权限的值为4,可写权限的值为2,加起来就是第一个数字6,第二、三个数字0表示组用户和其他人什么权限都没有。

文件的所有者是可以改变的,下面命令把foo文件的所有者改为bar用户,所属组改为root:

$ chown bar:root foo

2. 考纲描述

5.3 Managing File Permissions and Ownership

Weight: 2

Description: Understanding and manipulating file permissions and ownership settings.

Key Knowledge Areas:

  • File and directory permissions and ownership

The following is a partial list of the used files, terms and utilities:

  • ls -l, ls -a
  • chmod, chown

 

下一节:5.4 特殊目录和文件

返回目录

评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
验证码
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
请输入"Drupal10"