创建存档
创建一个名为
/root/backup.tar.gz
的 tar 存档,其应包含/usr/local
的 tar 存档,其应包含/usr/local
的内容。该 tar 存档必须使用gzip
进行压缩。
1 | [root@node1 ~]# tar -czvf /root/backup.tar.gz /usr/local |
创建存档
创建一个名为
/root/backup.tar.gz
的 tar 存档,其应包含/usr/local
的 tar 存档,其应包含/usr/local
的内容。该 tar 存档必须使用gzip
进行压缩。
1 | [root@node1 ~]# tar -czvf /root/backup.tar.gz /usr/local |
查找字符串
查找文件
/usr/share/xml/iso-codes/iso_639_3.xml
中包含字符串ng
的所有行。将所有这些行的副本按原始顺序放在文件/root/list
中。/root/list
不得包含空行,且所有行必须是/usr/share/xml/iso-codes/iso_639_3.xml
中原始行的确切副本。
1 | [root@node1 ~]# grep ng /usr/share/xml/iso-codes/iso_639_3.xml > /root/list |
创建脚本
创建一个名为
myresearch
的脚本该脚本放置在
/usr/bin
下该脚本用来查找
/usr
下所有小于10m
且具有修改SGID
权限的文件,将这些文件名称放置于/root/myfiles
文件中
创建脚本
创建一个名为
newsearch
的脚本该脚本放置在
/usr/bin
下该脚本用来查找
/usr
下所有大于30k
,但是小于50k
且具有SUID
权限的文件,将这些文件名列表保存在/root/newfiles
文件中
1 | [root@node1 ~]# find /usr -size -10M -perm /2000 | xargs ls -lh |
1 | [root@node1 ~]# find /usr -size +30k -size -50k -perm /4000 | xargs ls -lh |
-perm 选项用于查找具有特定权限集的文件。权限可以描述为八进制值,包含代表读取、写入和执行的 4、2 和 1 的某些组合。权限前面可以加上 / 或 - 符号。
前面带有 / 的数字权限将匹配文件的用户、组、其他人权限集中的至少一位。权限为 r--r--r-- 的文件并不匹配 /222,权限为 rw-r--r-- 的文件才匹配。权限前带有 - 符号表示该位的所有三个实例都必须存在,因此前面的两个示例都不匹配,但诸如 rw-rw-rw- 的对象则匹配。
与 / 或 - 一起使用时,0 值类似于通配符,因此其表示至少无任何内容的权限。
查找文件
查找归
jacques
所有的所有文件并将其副本放入/root/findfiles
目录
1 | [root@node1 ~]# mkdir /root/findfiles |
Using the find -exec Command Option
5. The Delimiter
We need to provide the find command with a delimiter so it'll know where our -exec arguments stop.
Two types of delimiters can be provided to the -exec argument: the semi-colon(;) or the plus sign (+).
As we don't want our shell to interpret the semi-colon, we need to escape it (\;).
The delimiter determines the way find handles the expression results. If we use the semi-colon (;), the -exec command will be repeated for each result separately. On the other hand, if we use the plus sign (+), all of the expressions' results will be concatenated and passed as a whole to the -exec command, which will run only once.
配置用户帐号
配置用户
manalo
,其用户 ID 为3533
。此用户的密码应当为flectrag
。
1 | [root@node1 ~]# useradd -u 3533 manalo |