-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30310b9
commit 3563135
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 文件权限 | ||
|
||
## 文件类型 | ||
|
||
* Linux系统使用了不同的字符来加以区分,常见的字符如下所示。 | ||
* -:普通文件。 | ||
* d:目录文件。 | ||
* l:链接文件。 | ||
* b:块设备文件。 | ||
* c:字符设备文件。 | ||
* p:管道文件。 | ||
|
||
使用ls -l命令看第一个字段的第一位就可以看到文件的类型 | ||
|
||
```shell | ||
[root@localhost ~]# ls -l anaconda-ks.cfg | ||
-rw-------. 1 root root 929 5月 18 2016 anaconda-ks.cfg | ||
``` | ||
|
||
## 文件的权限 | ||
|
||
使用ls -l查看文件信息,第一个字段第一位是文件类型,第一个字段中剩下的9位代表文件的权限,9位分为三组,分别是用户权限、用户所属组权限、其他用户权限,每组中都有读、写、执行三种权限 | ||
|
||
文件权限 | ||
|
||
![文件权限](https://s1.ax1x.com/2018/12/11/FJgQjs.jpg) | ||
|
||
## 修改文件权限 | ||
|
||
### chown | ||
|
||
此命令专门用来修改文件或目录的所属用户或者组 | ||
|
||
将当前目录下test1.txt文件属主改为root | ||
|
||
```shell | ||
# chown root test.txt | ||
``` | ||
|
||
将当前目录下test2.txt文件属主改为demon,文件的属组改为eagle | ||
|
||
第一种,两条命令修改 | ||
|
||
```shell | ||
# chown demon test2.txt | ||
# chgrp eagle test2.txt 或 # chown :eagle test2.txt | ||
``` | ||
|
||
第二种,一条命令搞定 | ||
|
||
```shell | ||
# chown demon:eagle test2.txt | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters