2017-07-24 每天2个Linux find命令_命令详解
find命令的一些常用参数的常用实例和用时的注意事项。
实例:
(1)-name参数:
1)[sunjimeng@localhost home]$ find ~ -name "less*" -print 在指定目录和指定目录的子目录中查找与文件名匹配的文件
[sunjimeng@localhost home]$ find ~ -name "less*" -print
/home/sunjimeng/Documents/less1
/home/sunjimeng/Documents/less2
~是一个代位符,表明的是个人目录的地址,因为每个用户都有自己的个人目录地址,
所以用 ~ 作为统一替代这个根据用户不同而不同但有规可循的地址,来保证某些情况下的兼容性问题。
如果以root登录,则~代表/home/root,若以username登录,则~代表/home/username,例如:我的目录就是/home/sunjimeng。
linux 中的$PATH $HOME 是什么意思?
在linux及unix的sh中,以$开头的字符串表示的是sh中定义的变量,
这些变量可以是系统自动增加的,也可以是用户自己定义的。 $PATH表示的是系统的命令搜索路径,
和windows的%path%是一样的;$HOME则表示是用户的主目录,也就是用户登录后工作目录。
波浪号~代表了你的$HOME目录。
2)[sunjimeng@localhost Document]$ find . -name "[A-Z]*[1-9]"
查找当前目录下以大写字母开头,数字结尾的文件。(注意[]符号的用法)
复制代码
[sunjimeng@localhost Document]$ ll
总用量 12
-rw-r--r--. 1 root root 85 5月 18 02:58 all.txt
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 B.text3
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 C.text6
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:28 D.text
drwxr-xr-x. 2 root root 51 5月 18 02:47 newDir
-rw-r--r--. 1 root root 42 5月 18 02:53 t1.txt
-rw-r--r--. 1 root root 43 5月 18 02:54 t2.txt
[sunjimeng@localhost Document]$ find . -name "[A-Z]*[1-9]"
./B.text3
./C.text6
[sunjimeng@localhost Document]$ find . -name "[A-Z]*"
./B.text3
./C.text6
./D.text
3)[sunjimeng@localhost Document]$ find / -name "*" 查找Linux文件系统中的所有文件,让系统高负荷运行
[sunjimeng@localhost Document]$ find / -name "*"
由于Linux的find命令是通过后台执行操作,遍历整个磁盘文件进行文件的查找,
不仅包括名称的查找,还包括其他的例如权限,文件的内容的字符串匹配的查找,
因此十分耗费资源,因此这里会让系统高负荷运行。而前几个命令,都是高效查询命令,
例如which,whereis等,因为他们不是直接深入磁盘中查找,而是通过数据库的键值对应进行快速查找。
(2)-perm参数
按照文件权限模式用-perm选项,按文件权限模式来查找文件的话。最好使用八进制的权限表示法。
1)[root@localhost home]# find . -perm 755 |more -5 按权限在目录中查找文件,并执行分页显示
复制代码
[root@localhost home]# find . -perm 755 |more -5
.
./sunjimeng/.mozilla
./sunjimeng/.mozilla/extensions
./sunjimeng/.mozilla/plugins
./sunjimeng/.config
--more-- //按q键退出more命令 回车下一行,空格下一页
2)[root@localhost home]# find / -perm -mode |more -5 根据权限查看文件,当权限值前有-号时
复制代码
[root@localhost home]# find / -perm 555 |more -5
/
/boot
/proc
/proc/asound
/proc/asound/card0
--more--
[root@localhost home]# find / -perm -555 |more -5
/
/boot
/boot/grub
/boot/grub2
/boot/grub2/themes
--more--
[root@localhost home]# find / -perm -005 |more -5
/
/boot
/boot/grub
/boot/grub2
/boot/grub2/themes
--more--
复制代码
find -perm,根据文件的权限来查找文件,有三种形式:
1.find -perm mode
表示严格匹配,也就是你的文件权限位转换成对应的十进制数字与mode一模一样,那么匹配成功,
需要注意的是如果mode给的数字不足3位,那么前面自动添0(严格的说是不足4位)
2.find -perm -mode
表示mode中转换成二进制的1在文件权限位里面必须匹配,比如mode=644那么转换成二进制为110 100 100,
而被查找的文件的权限位也可以被转换成一个二进制数,两者在位上为1的部分必须完全匹配,而0则不管。
例如被查找的文件的权限为转换成二进制数是111 111 111那么这个比如被匹配,
而假如是100 100 100那么则不会匹配。所以这个'-'的作用归结起来就是匹配比mode权限更充足的文件
3.find -perm +mode
与 -mode的区别是+mode只需其中的任意一个1的部分被匹配,-mode是所有1的部分都必须被匹配,同样+mode也不管0位。
在linux中文件或目录有三者权限r,w,x,代表的含义分别是读、写、可执行。
而一个文件或目录的属性中又包括所属用户u、所属组g、其他o三个部分的属性,
分别表示所属用户、所属组、其他用户对这个文件所拥有的权限。看起来大概是这个样子:
所属用户 所属组 其他
rwx rwx rwx
用户在其拥有权限的位上设置1,没有权限的位设置0。如果将每个部分的这些权限位看成二进制数,
每个部分可以用3位二进制数表示,最大值为7(2^3-1),表示可读、可写、可执行。
(3) -prune参数:
如果在查找文件时希望忽略某个目录,因为你知道那个目录中没有你所要查找的文件,
那么可以使用-prune选项来指出需要忽略的目录。在使用-prune选项时要当心,
因为如果你同时使用了-depth选项,那么-prune选项就会被find命令忽略。
1)[root@localhost sunjimeng]# find Document -path "Document/newDir" -prune -o -print
查询文件时忽略特定目录
复制代码
[root@localhost sunjimeng]# find Document
Document
Document/newDir
Document/newDir/mvt1.txt
Document/newDir/mvt2.txt
Document/newDir/mvt3.txt
Document/t1.txt
Document/t2.txt
Document/all.txt
Document/B.text3
Document/C.text6
Document/D.text
[root@localhost sunjimeng]# find Document -path "Document/newDir" -prune -o -print
Document
Document/t1.txt
Document/t2.txt
Document/all.txt
Document/B.text3
Document/C.text6
Document/D.text
2)[root@localhost sunjimeng]# find Document -path "Document/newDir" -prune
find命令后默认只能跟一个参数命令,如果还需要执行其他的命令,需要-o命令连接符
复制代码
[root@localhost sunjimeng]# find Document -path "Document/newDir" -prune
//-prune不加-print命令的话,输出的是要忽略的文件夹及其路径
Document/newDir
[root@localhost sunjimeng]# find Document -path "Document/newDir" -prune -o -exec ls -l {} \;
-o用于设置执行的两个连续的命令,这里执行-exec命令,上一个命令执行的是-print命令,也可以换成其他的
总用量 12
-rw-r--r--. 1 root root 85 5月 18 02:58 all.txt
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 B.text3
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 C.text6
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:28 D.text
drwxr-xr-x. 2 root root 51 5月 18 02:47 newDir
-rw-r--r--. 1 root root 42 5月 18 02:53 t1.txt
-rw-r--r--. 1 root root 43 5月 18 02:54 t2.txt
-rw-r--r--. 1 root root 42 5月 18 02:53 Document/t1.txt
-rw-r--r--. 1 root root 43 5月 18 02:54 Document/t2.txt
-rw-r--r--. 1 root root 85 5月 18 02:58 Document/all.txt
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 Document/B.text3
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 Document/C.text6
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:28 Document/D.text
复制代码
3)[root@localhost Documents]# find . \( -path "./Dir" -o -path "./findDir" \) -prune -o -exec ls -l {} \;
忽略多个文件夹
复制代码
[root@localhost Documents]# ll
总用量 28
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
-rw-r--r--. 1 root root 0 5月 19 04:16 find
drwxr-xr-x. 2 root root 84 5月 19 04:57 findDir //是文件夹
--w-------. 1 root root 664 5月 9 07:59 head_text
--w-------. 1 root root 45 5月 9 08:15 less1
--w-------. 1 root root 57 5月 9 08:16 less2
--w-------. 1 root root 0 5月 15 18:21 newlocate
-rw-r--r--. 1 root root 85 5月 19 04:25 t3.txt
--w-------. 1 root root 259 5月 12 21:53 tail_text
--w-------. 1 root root 216 5月 12 22:24 tempory
--w-------. 1 root root 0 5月 15 18:34 uText
[root@localhost Documents]# mkdir Dir //新建一个文件夹
[root@localhost Documents]# mv {head_text,less1,less2} Dir //将几个文件移到里面
[root@localhost Documents]# ll
总用量 16
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
drwxr-xr-x. 2 root root 46 5月 19 23:29 Dir
-rw-r--r--. 1 root root 0 5月 19 04:16 find
drwxr-xr-x. 2 root root 84 5月 19 04:57 findDir
--w-------. 1 root root 0 5月 15 18:21 newlocate
-rw-r--r--. 1 root root 85 5月 19 04:25 t3.txt
--w-------. 1 root root 259 5月 12 21:53 tail_text
--w-------. 1 root root 216 5月 12 22:24 tempory
--w-------. 1 root root 0 5月 15 18:34 uText
[root@localhost Documents]# find . -exec ls -l {} \;
//执行一次查询当前Documents文件夹下的所有目录及文件操作
总用量 16
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
drwxr-xr-x. 2 root root 46 5月 19 23:29 Dir
-rw-r--r--. 1 root root 0 5月 19 04:16 find
drwxr-xr-x. 2 root root 84 5月 19 04:57 findDir
--w-------. 1 root root 0 5月 15 18:21 newlocate
-rw-r--r--. 1 root root 85 5月 19 04:25 t3.txt
--w-------. 1 root root 259 5月 12 21:53 tail_text
--w-------. 1 root root 216 5月 12 22:24 tempory
--w-------. 1 root root 0 5月 15 18:34 uText
--w-------. 1 root root 259 5月 12 21:53 ./tail_text
--w-------. 1 root root 216 5月 12 22:24 ./tempory
--w-------. 1 root root 0 5月 15 18:21 ./newlocate
--w-------. 1 root root 0 5月 15 18:34 ./uText
总用量 0
--w-------. 1 root root 0 5月 17 04:18 p1.pdf
--w-------. 1 root root 0 5月 17 04:18 p2.pdf
--w-------. 1 root root 0 5月 17 03:50 t1.txt
--w-------. 1 root root 0 5月 17 04:02 T1.txt
-rw-r--r--. 1 root root 0 5月 19 04:58 t2.txt
--w-------. 1 root root 0 5月 17 04:02 T2.txt
--w-------. 1 root root 0 5月 17 03:50 ./findDir/t1.txt
--w-------. 1 root root 0 5月 17 04:02 ./findDir/T1.txt
--w-------. 1 root root 0 5月 17 04:02 ./findDir/T2.txt
--w-------. 1 root root 0 5月 17 04:18 ./findDir/p1.pdf
--w-------. 1 root root 0 5月 17 04:18 ./findDir/p2.pdf
-rw-r--r--. 1 root root 0 5月 19 04:58 ./findDir/t2.txt
-rw-r--r--. 1 root root 0 5月 19 04:16 ./find
-rw-r--r--. 1 root root 27 5月 19 04:21 ./core.log
-rw-r--r--. 1 root root 85 5月 19 04:25 ./t3.txt
总用量 12
--w-------. 1 root root 664 5月 9 07:59 head_text
--w-------. 1 root root 45 5月 9 08:15 less1
--w-------. 1 root root 57 5月 9 08:16 less2
--w-------. 1 root root 664 5月 9 07:59 ./Dir/head_text
--w-------. 1 root root 45 5月 9 08:15 ./Dir/less1
--w-------. 1 root root 57 5月 9 08:16 ./Dir/less2
[root@localhost Documents]# find . \( -path "./Dir" -o -path "./findDir" \) -prune -o -exec ls -l {} \;
//忽略两个文件夹,执行操作
总用量 16
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
drwxr-xr-x. 2 root root 46 5月 19 23:29 Dir
-rw-r--r--. 1 root root 0 5月 19 04:16 find
drwxr-xr-x. 2 root root 84 5月 19 04:57 findDir
--w-------. 1 root root 0 5月 15 18:21 newlocate
-rw-r--r--. 1 root root 85 5月 19 04:25 t3.txt
--w-------. 1 root root 259 5月 12 21:53 tail_text
--w-------. 1 root root 216 5月 12 22:24 tempory
--w-------. 1 root root 0 5月 15 18:34 uText
--w-------. 1 root root 259 5月 12 21:53 ./tail_text
--w-------. 1 root root 216 5月 12 22:24 ./tempory
--w-------. 1 root root 0 5月 15 18:21 ./newlocate
--w-------. 1 root root 0 5月 15 18:34 ./uText
-rw-r--r--. 1 root root 0 5月 19 04:16 ./find
-rw-r--r--. 1 root root 27 5月 19 04:21 ./core.log
-rw-r--r--. 1 root root 85 5月 19 04:25 ./t3.txt
[root@localhost Documents]# find . \( -path "./Dir" -o -path "findDir" \) -prune -o -exec ls -l {} \;
不加./是无法进行匹配的,-path “findDir”无意义(根据结果可知)
总用量 16
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
drwxr-xr-x. 2 root root 46 5月 19 23:29 Dir
-rw-r--r--. 1 root root 0 5月 19 04:16 find
drwxr-xr-x. 2 root root 84 5月 19 04:57 findDir
--w-------. 1 root root 0 5月 15 18:21 newlocate
-rw-r--r--. 1 root root 85 5月 19 04:25 t3.txt
--w-------. 1 root root 259 5月 12 21:53 tail_text
--w-------. 1 root root 216 5月 12 22:24 tempory
--w-------. 1 root root 0 5月 15 18:34 uText
--w-------. 1 root root 259 5月 12 21:53 ./tail_text
--w-------. 1 root root 216 5月 12 22:24 ./tempory
--w-------. 1 root root 0 5月 15 18:21 ./newlocate
--w-------. 1 root root 0 5月 15 18:34 ./uText
总用量 0
--w-------. 1 root root 0 5月 17 04:18 p1.pdf
--w-------. 1 root root 0 5月 17 04:18 p2.pdf
--w-------. 1 root root 0 5月 17 03:50 t1.txt
--w-------. 1 root root 0 5月 17 04:02 T1.txt
-rw-r--r--. 1 root root 0 5月 19 04:58 t2.txt
--w-------. 1 root root 0 5月 17 04:02 T2.txt
--w-------. 1 root root 0 5月 17 03:50 ./findDir/t1.txt
--w-------. 1 root root 0 5月 17 04:02 ./findDir/T1.txt
--w-------. 1 root root 0 5月 17 04:02 ./findDir/T2.txt
--w-------. 1 root root 0 5月 17 04:18 ./findDir/p1.pdf
--w-------. 1 root root 0 5月 17 04:18 ./findDir/p2.pdf
-rw-r--r--. 1 root root 0 5月 19 04:58 ./findDir/t2.txt
-rw-r--r--. 1 root root 0 5月 19 04:16 ./find
-rw-r--r--. 1 root root 27 5月 19 04:21 ./core.log
-rw-r--r--. 1 root root 85 5月 19 04:25 ./t3.txt
(4)-user参数
1)[root@localhost Document]# find . -user sunjimeng -exec ls -l {} \;
查找属于特定用户的文件及文件夹
复制代码
[root@localhost Document]# find . -user sunjimeng -exec ls -l {} \;
总用量 12
-rw-r--r--. 1 root root 85 5月 18 02:58 all.txt
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 B.text3
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 C.text6
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:28 D.text
drwxr-xr-x. 2 root root 51 5月 18 02:47 newDir
-rw-r--r--. 1 root root 42 5月 18 02:53 t1.txt
-rw-r--r--. 1 root root 43 5月 18 02:54 t2.txt
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 ./B.text3
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:27 ./C.text6
-rw-rw-r--. 1 sunjimeng sunjimeng 0 5月 19 22:28 ./D.text
[root@localhost Document]# find . -user root -exec ls -l {} \;
总用量 0
-rw-r--r--. 1 root root 0 5月 18 02:46 mvt1.txt
-rw-r--r--. 1 root root 0 5月 18 02:46 mvt2.txt
-rw-r--r--. 1 root root 0 5月 18 02:46 mvt3.txt
-rw-r--r--. 1 root root 0 5月 18 02:46 ./newDir/mvt1.txt
-rw-r--r--. 1 root root 0 5月 18 02:46 ./newDir/mvt2.txt
-rw-r--r--. 1 root root 0 5月 18 02:46 ./newDir/mvt3.txt
-rw-r--r--. 1 root root 42 5月 18 02:53 ./t1.txt
-rw-r--r--. 1 root root 43 5月 18 02:54 ./t2.txt
-rw-r--r--. 1 root root 85 5月 18 02:58 ./all.txt
2)[root@localhost /]# find . -nouser -exec ls -l {} \; 查找不属于任何用户的文件
[root@localhost /]# find . -nouser -exec ls -l {} \; //这里没找着
find: ‘./proc/37913/task/37913/fd/6’: 没有那个文件或目录
find: ‘./proc/37913/task/37913/fdinfo/6’: 没有那个文件或目录
find: ‘./proc/37913/fd/6’: 没有那个文件或目录
find: ‘./proc/37913/fdinfo/6’: 没有那个文件或目录
find: ‘./run/user/1000/gvfs’: 权限不够
另外,还有其他的参数,例如按文件的大小-size,按查询路径的深度-depth,按文件的新旧程度-newer,
按更改时间或访问时间-mtime,按类型-type等等。
在此并不一一举例。况且前两篇也有一些示例。
2017-07-24 每天2个Linux chmod命令
chmod命令用来变更文件或目录的权限。
在UNIX系统家族里,文件或目录权限的控制分别以读取、写入、执行3种一般权限来区分,
另有3种特殊权限可供运用。用户可以使用chmod指令去变更文件与目录的权限,
设置方式采用文字或数字代号皆可。符号连接的权限无法变更,如果用户对符号连接修改权限,
其改变会作用在被连接的原始文件。
(1)用法:
用法: chmod [选项] [mode] 模式 文件
或 chmod [-cfvR] [--help] [--version] mode file
命令有两种用法:一种是包含字母和操作符表达式的文字设定法;另一种是包含数字的数字设定法。
(2)功能:
功能:用于改变文件或目录的访问权限,用它控制文件或目录的访问权限。
(3)参数详解:
1) -R ——recursive: 递归处理,将指令目录下的所有文件及子目录一并处理
2) -v ——verbose : 显示指令执行过程
3) --reference=<参考文件或目录>: 把指定文件或目录的所属群组全部设成和参考文件或目录的所属群组相同
4) <权限范围>+<权限设置>: 开启权限范围的文件或目录的该选项权限设置
<权限范围> -<权限设置>: 关闭权限范围的文件或目录的该选项权限设置
<权限范围>=<权限设置>: 指定权限范围的文件或目录的该选项权限设置
(4)权限范围的表示法:
1) u User 即文件或目录的拥有者
2) g Group 即文件或目录的所属群组
3) o Other 除了文件或目录拥有者或所属群组之外,其他用户皆属于这个范围
4) a All 即全部的用户,包含拥有者,所属群组以及其他用户
5) r 读取权限,数字代号为“4”
6) w 写入权限,数字代号为“2”
7) x 执行或切换权限,数字代号为“1”
8) - 不具任何权限,数字代号为“0”
9) s 特殊功能说明:变更文件或目录的权限
(5)实例:
1)[root@localhost Documents]# chmod a+x core.log 为所有用户组添加可执行权限
复制代码
[root@localhost Documents]# ll -al core.log //ll -al 文件名与 ls -l 文件名貌似没啥区别
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
[root@localhost Documents]# ls -l core.log
-rw-r--r--. 1 root root 27 5月 19 04:21 core.log
[root@localhost Documents]# chmod a+x core.log
[root@localhost Documents]# ll -al core.log
-rwxr-xr-x. 1 root root 27 5月 19 04:21 core.log
2)[root@localhost Documents]# chmod ug+w,o-x core.log 同时为不同用户添加或删除权限
[root@localhost Documents]# ll -al core.log
-rwxr-xr-x. 1 root root 27 5月 19 04:21 core.log
[root@localhost Documents]# chmod ug+w,o-x core.log
[root@localhost Documents]# ll -l core.log
-rwxrwxr--. 1 root root 27 5月 19 04:21 core.log
3)[root@localhost Documents]# chmod g=x,o=rwx core.log
设置文件的u,g,o的三个权限。这里是设置文件所有者权限为可执行,其他用户可以读写执行,组用户权限不变
[root@localhost Documents]# ll -l core.log
-rwxrwxr--. 1 root root 27 5月 19 04:21 core.log
[root@localhost Documents]# chmod g=x,o=rwx core.log
[root@localhost Documents]# ls -l core.log
-rwx--xrwx. 1 root root 27 5月 19 04:21 core.log
4)[root@localhost Documents]# chmod -R o=--- findDir
递归的设置findDir文件夹下的文件及文件夹的其他用户权限为不具备任何权限
复制代码
[root@localhost Documents]# chmod -R o=--- findDir
[root@localhost Documents]# find . -name "Dir" -print
./Dir
[root@localhost Documents]# find . -name "Dir" -exec ls -l {} \;
总用量 12
--w-------. 1 root root 664 5月 9 07:59 head_text
--w-------. 1 root root 45 5月 9 08:15 less1
--w-------. 1 root root 57 5月 9 08:16 less2
[root@localhost Documents]# ls -l Dir
总用量 12
--w-------. 1 root root 664 5月 9 07:59 head_text
--w-------. 1 root root 45 5月 9 08:15 less1
--w-------. 1 root root 57 5月 9 08:16 less2
5)[root@localhost Documents]# chmod -R u=r,g=r,o=r findDir 与
[root@localhost Documents]# chmod -R =rx Dir 等价地给ugo的用户设置权限
复制代码
[root@localhost Documents]# chmod -R u=r,g=r,o=r findDir
[root@localhost Documents]# ls -l findDir
总用量 0
-r--r--r--. 1 root root 0 5月 17 04:18 p1.pdf
-r--r--r--. 1 root root 0 5月 17 04:18 p2.pdf
-r--r--r--. 1 root root 0 5月 17 03:50 t1.txt
-r--r--r--. 1 root root 0 5月 17 04:02 T1.txt
-r--r--r--. 1 root root 0 5月 19 04:58 t2.txt
-r--r--r--. 1 root root 0 5月 17 04:02 T2.txt
[root@localhost Documents]# ls -l Dir
总用量 12
--w-------. 1 root root 664 5月 9 07:59 head_text
--w-------. 1 root root 45 5月 9 08:15 less1
--w-------. 1 root root 57 5月 9 08:16 less2
[root@localhost Documents]# chmod -R =rx Dir //设置所有组用户权限为rw之后,以前的所有者的w权限就没了
[root@localhost Documents]# ls -l Dir
总用量 12
-r-xr-xr-x. 1 root root 664 5月 9 07:59 head_text
-r-xr-xr-x. 1 root root 45 5月 9 08:15 less1
-r-xr-xr-x. 1 root root 57 5月 9 08:16 less2
6)[root@localhost Documents]# chmod 444 find 用数字给文件设置权限
[root@localhost Documents]# chmod 444 find
[root@localhost Documents]# ls -l find
-r--r--r--. 1 root root 0 5月 19 04:16 find
[root@localhost Documents]# chmod =r newlocate //两种方法等价,但同时都会将原有的权限清除
[root@localhost Documents]# ls -l newlocate
-r--r--r--. 1 root root 0 5月 15 18:21 newlocate
(6)其他:
Linux用户分为:拥有者、组群(Group)、其他(other)。
Linux系统中,预设的情況下,系统中所有的帐号与一般身份使用者,以及root的相关信息,
都是记录在/etc/passwd文件中。每个人的密码则是记录在/etc/shadow文件下。 此外,所有的组群名称记录在/etc/group內!
分类: CentOS服务器管理