目录与路径
常见处理目录的命令
- cd:切换目录
- pwd:显示当前目录
- mkdir:创建目录
- rmdir:删除空目录
目录相关
递归创建目录/文件
mkdir [-p] 目录名称 ```shell [root@xxxxxx app]# mkdir -p dir/doc/test [root@xxxxxx app]# tree dir/ dir/ └── doc └── test 2 directories, 0 files
删除目录
[root@xxxxxx app]# cd dir/ [root@xxxxxx dir]# rmdir doc/ rmdir: failed to remove ‘doc/’: Directory not empty
删除空目录
[root@xxxxxx dir]# cd doc/ [root@xxxxxx doc]# rmdir test/ [root@xxxxxx doc]#
<a name="bALJW"></a>
#### 关于执行文件路径的变量:$PATH
A:ls命令完整的文件路径为/bin/ls,但我们确认在任何路径下都能执行ls?<br />Q:因为环境变量PATH所致
输出环境变量(PATH一定是大写)
```shell
root@xxxxxx doc]# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
PATH注意事项
- 不同身份用户默认的PTH不同,默认能够随意执行的命令不同(如root、shigl)
- PATH是可以修改的
- 使用绝对路径或相对路径直接指定某个命令的文件来执行,会比查PATH来的准确
- 命令应该要放置到正确的目录下,执行才会方便
-
文件与目录管理
文件与目录相关操作
文件/目录查看命令
ls
参数与选项-a:全部文件,连同隐藏文件一起列出 (常用)
-A:全部文件,连同隐藏文件,但不包括.和..两个目录
-d:仅列出目录本身,而不列出目录内的文件数据 (常用)
-f:直接列出结果,而不进行排序(ls默认会按文件名排序)
-h:将文件容量以人类易读的方式(如GB、KB等)列出来
-i:列出inode号码
-l:列出详细属性与权限等数据 (常用)
-n:列出UID与GID而非使用者和用户组的名称
-r:将排序结果反向输出
-R:连同子目录内容一起列出来,等于该目录下的所有文件都会显示出来
-S:以文件容量大小排序,而非文件名
-t:以时间排序,而非文件名
--full-time:以完整时间(包含 年/月/日/时/分)模式输出
文件/目录操作命令
cp(复制文件或目录)
cp [-adfilprsu] 源文件(source) 目标文件(destination)
cp [options] source1 source2 source3 directory
参数与选项
注意:-a:相当于-dr --preserver=all
-d:若源文件为链接文件的属性,则复制链接文件的属性而非文件本身
-f:为强制(force)的意思,若目标文件已经存在且无法启用,则删除后再尝试一次
-i:若目标文件见已经存在,在覆盖时会先询问操作的进行 (常用)
-l:进行硬链接(hard link)的链接文件建立,而非复制文件本身
-p:连同文件的属性(权限、用户、时间)一起复制过去,而非使用默认属性 (备份常用)
-r:递归复制,用于目录的复制操作 (常用)
-s:复制为符号链接文件(symbolic link),亦称 '快捷方式'文件
-u:destination比source旧才更新destination比source,或destination不存在的情况才复制
--preserver=all:除-p的权限相关参数外,还加入SELinux的属性,links、xattr等也复制
- 如果源文件是两个以上的文件,则目标文件一定要是 “目录”
- 默认情况,cp的源文件和目标文件权限是不同的,目标文件拥有者通常会是命令操作的本身
软连接&硬链接
[root@xxxxxx linux_basic]# ll
total 0
-rw-r--r-- 1 root root 0 Aug 5 19:52 test-shig.py
[root@xxxxxx linux_basic]# cp -l test-shig.py test-william.py
[root@xxxxxx linux_basic]# ll
total 0
-rw-r--r-- 2 root root 0 Aug 5 19:52 test-shig.py
-rw-r--r-- 2 root root 0 Aug 5 19:52 test-william.py
[root@xxxxxx linux_basic]# cp -s test-shig.py test-william001.py
[root@xxxxxx linux_basic]# ll
total 0
-rw-r--r-- 2 root root 0 Aug 5 19:52 test-shig.py
lrwxrwxrwx 1 root root 12 Aug 5 20:15 test-william001.py -> test-shig.py
-rw-r--r-- 2 root root 0 Aug 5 19:52 test-william.py
mv(删除文件或目录)
rm [-fir] 文件或目录
选项与参数
注意:直接rm 不带任何参数时,默认有-i选项-f:force的意思,忽略不存在的文件,也不会出现警告信息
-i:交互模式,删除前会询问使用者是否操作
-r:递归删除,最常用于目录的删除,这是非常危险的选项
rm(移动文件与目录,或重命名)
mv [-fiu] source destination
mv [options] source1 source2 source3 directory
选项与参数-f:force的意思,如果目标文件存在,不会询问直接覆盖
-i:若目标文件已经存在,就会询问是否覆盖
-u:若目标文件已经存在,且source比较新,才会更新
获取文件名与目录名
basename ```shell [root@xxxxxx linux_basic]# ll total 0 -rw-r—r— 1 root root 0 Aug 5 19:52 test-william.py
取到的是文件名
[root@xxxxxx linux_basic]# basename /app/linux_basic/test-william.py test-william.py
- dirname
```shell
# 取到的是目录名
[root@xxxxxx linux_basic]# dirname /app/linux_basic/test-william.py
/app/linux_basic
直接查看文件内容
cat(concatenate)
cat [-AbEnTv]
选项与参数
基本使用-A:相当于-vET
-b:列出行号,仅针对非空白做行号显示,空白行不标行号
-E:将结尾的$显示出来
-n:打印出行号,连同空行也会有行号,与-b的选项不同
-T:将[tab]案件已^I显示出来
-v:列出一些看不出的特殊字符
[root@cnsz92vl12951 linux_basic]# cat -n test-william.py
1 # coding=utf-8
2
3 print 123
tac(反向列示) ```shell [root@xxxxxx linux_basic]# cat test-william.py
coding=utf-8
print 123 [root@xxxxxx linux_basic]# tac test-william.py print 123
coding=utf-8
- nl(添加行号打印)<br />nl [-bnw] 文件<br />选项与参数 <br />nl及带参数使用 <br />说明:nl 和cat -n都能对文件内容自动加行号,区别是nl可以将行号做比较多的显示设计,包括位数是否自动补齐0等功能
```shell
-b:指定行号指定的方式,主要有两种:
-b a:表示无论是否为空行,也同样列出行号
-b t:表示有空行,空的行不要列出行号(默认)
-n:列出行号表示的方法,主要有三种:
-n ln:行号在屏幕最左方显示
-n rn:行号在自己栏最右方显示,且不加0
-n rz:行号在自己栏最右方显示,且加0
[root@xxxxxx linux_basic]# nl test-william.py
1 # coding=utf-8
2 print 123
# 空行也列出行号
[root@cnsz92vl12951 linux_basic]# nl -ba test-william.py
1 # coding=utf-8
2
3 print 123
# 行号在屏幕最左方显示
[root@cnsz92vl12951 linux_basic]# nl -n ln test-william.py
1 # coding=utf-8
2 print 123
# 行号在自己栏最右方显示,且不加0
[root@cnsz92vl12951 linux_basic]# nl -n rn test-william.py
1 # coding=utf-8
2 print 123
# 行号在自己栏最右方显示,且加0
[root@cnsz92vl12951 linux_basic]# nl -n rz test-william.py
000001 # coding=utf-8
000002 print 123
翻页查看
数据截取
练习:查看文件第11到20行的数据
# 原文件内容
10
11
12 class SmallRice(SimpleFactory):
13
14 def make(self):
15 return "make small rice"
16
17
18 class Apple(SimpleFactory):
19
20 def make(self):
# 查看文件第11到20行的数据的命令
[root@cnsz92vl12951 linux_basic]# head -n 20 factory.py | tail -n 10
class SmallRice(SimpleFactory):
def make(self):
return "make small rice"
class Apple(SimpleFactory):
def make(self):
# 查看文件第11到20行的数据并显示行号
[root@cnsz92vl12951 linux_basic]# cat -n factory.py | head -n 20 | tail -n 10
11
12 class SmallRice(SimpleFactory):
13
14 def make(self):
15 return "make small rice"
16
17
18 class Apple(SimpleFactory):
19
20 def make(self):
非纯文本文件:od
修改文件时间&创建新文件:touch
- 修改时间(modification time, mtime)
文件内容更新时,就会更新这个时间。 - 状态时间(status time, ctime)
文件状态改变,就会更新这个时间,比如:权限、属性 - 读取时间(access time, atime)
文件内容被读取时,就会更新这个时间,比如cat操作 ```shell [root@cnsz92vl12951 etc]# date; ls -l —full-time man_db.conf ; ls -l —full-time —time=atime man_db.conf ; ls -l —full-time —time=ctime man_db.conf Fri Aug 6 10:02:07 CST 2021 -rw-r—r— 1 root root 5171 2018-10-31 04:26:28.000000000 +0800 man_db.conf # 修改时间 -rw-r—r— 1 root root 5171 2021-08-06 09:53:30.089485561 +0800 man_db.conf # 更新状态时间 -rw-r—r— 1 root root 5171 2021-05-24 20:04:41.941080211 +0800 man_db.conf # 读取时间
[root@cnsz92vl12951 etc]# ll —full-time man_db.conf -rw-r—r— 1 root root 5171 2018-10-31 04:26:28.000000000 +0800 man_db.conf
说明:默认情况下,ls显示的是该文件的mtime
- touch<br />touch [-acdmt] 文件<br />选项与参数 <br />修改文件时间 <br />新建空文件
```shell
-a:仅自定义access time
-c:仅修改文件的时间,若文件不存在则不建立新文件
-d:后面接要自定义的日期,也可以使用--date="日期或时间"
-m:仅修改mtime
-t:后面接要自定义的时间,格式为[YYYYMMDDhhmm]
# 查看当前时间
[root@cnsz92vl12951 linux_basic]# date
Fri Aug 6 10:16:40 CST 2021
# 查看文件的更新时间
[root@cnsz92vl12951 linux_basic]# ll --full-time test-william.py
-rw-r--r-- 1 root root 26 2021-08-05 20:47:16.309165985 +0800 test-william.py
# 更新文件的时间为2天前
[root@cnsz92vl12951 linux_basic]# touch -d "2 days ago" test-william.py
[root@cnsz92vl12951 linux_basic]# ll --full-time test-william.py
-rw-r--r-- 1 root root 26 2021-08-04 10:16:04.601836299 +0800 test-william.py
# 更新时间为202108011200
[root@cnsz92vl12951 linux_basic]# touch -t 202108011200 test-william.py
[root@cnsz92vl12951 linux_basic]# ll --full-time test-william.py
-rw-r--r-- 1 root root 26 2021-08-01 12:00:00.000000000 +0800 test-william.py
[root@cnsz92vl12951 linux_basic]# touch william.py
[root@cnsz92vl12951 linux_basic]# ll
total 12
-rw-r--r-- 1 root root 26 Aug 1 12:00 test-william.py
-rw-r--r-- 1 root root 0 Aug 6 10:26 william.py
文件与目录的默认权限与隐藏权限
默认权限
- 用户创建为文件则默认没有可执行权限,即只有rw这两项,即最大为666,-rw-rw-rw-
- 用户创建为目录,由于x与是否可进入目录有关,因此所有权限均开放,即最大777,drwxrwxrwx
文件默认权限:umask
问题:新增一个文件或目录,默认权限是什么?
查看umask ```shell [root@cnsz92vl12951 linux_basic]# umask 0022
[root@cnsz92vl12951 linux_basic]# umask -S u=rwx,g=rx,o=rx
**说明:**022表示需**要移除**的权限,**文件移除后为:-rw-r--r--;目录移除后为:rwxr-xr-x**<br />**新建文件&目录的默认权限**
```shell
[root@cnsz92vl12951 linux_basic]# mkdir dir
[root@cnsz92vl12951 linux_basic]# touch dir.py
[root@cnsz92vl12951 linux_basic]# ll
total 12
drwxr-xr-x 2 root root 6 Aug 6 10:33 dir
-rw-r--r-- 1 root root 0 Aug 6 10:33 dir.py
设置umask
[root@cnsz92vl12951 linux_basic]# umask
0022
# 设置umask值
[root@cnsz92vl12951 linux_basic]# umask值 002
[root@cnsz92vl12951 linux_basic]# umask
0002
# 此时用户组也具有w权限了
[root@cnsz92vl12951 linux_basic]# touch test-dir.py
[root@cnsz92vl12951 linux_basic]# mkdir test-dir
[root@cnsz92vl12951 linux_basic]# ll
drwxrwxr-x 2 root root 6 Aug 6 10:47 test-dir
-rw-rw-r-- 1 root root 0 Aug 6 10:47 test-dir.py
文件隐藏属性
文件的隐藏属性对系统有很大的帮助,尤其在系统安全上面,需要强调的是,chattr命令只能在ext2、ext3、ext4的linux传统文件系统上面完整生效,其他文件系统可能无法完整生效。
- chattr(配置文件隐藏属性)
chattr [+-=] [ASacdistu] 文件/目录名称
选项与参数:
注意:设置属性常见的a与i的设置值,而且很多设置值必须要root才能设置 ```shell +:增加某一特殊参数,其他原本存在参数则不动 -:删除某一特殊参数,其他原本存在参数则不动 =:直接设置参数,且仅有后面接的参数 A:当设置A属性后,若存取文件(目录)时,它的存取时间atime将不会被修改,可避免I/O较慢的机器过度的读写磁盘 S:一般文件是非同步写入磁盘的,增加S属性时,当进行任何文件的修改,该修改会同步写入磁盘中
a:当设置a后,这个文件只能增加数据,不能删除也不能修改数据,只有root才能设置这个属性
c:当设置c后,会自动的将文件[压缩],在读取的时候将会自动解压缩,但是在存储的时候,将会先进行压缩后再存储(对大文件似乎挺有用) d:当dump程序被执行时,设置d属性将可使该文件(目录)不会被dump备份 i:可以让一个文件[不能被删除、改名、设置链接也无法写入或新增数据],对系统安全性有相当大的助益,只有root才能设置这个属性 s:当文件设置s属性后,如果文件被删除,它将完全的从硬盘删除,所以如果误删,完全无法恢复 u:与s相反,如果该文件删除了,则数据内容其实还存在磁盘中,可以用来恢复该文件
重点:如对文件安全要求高,i和a参数比较常用
```shell
[root@cnsz92vl12951 linux_basic]# cd dir/
[root@cnsz92vl12951 dir]# ll
total 0
[root@cnsz92vl12951 dir]# touch attr_test.py
[root@cnsz92vl12951 dir]# chattr +i attr_test.py
[root@cnsz92vl12951 dir]# rm -rf attr_test.py
rm: cannot remove ‘attr_test.py’: Operation not permitted
# 移除文件隐藏属性
[root@cnsz92vl12951 dir]# chattr -i attr_test.py
[root@cnsz92vl12951 dir]# lsattr attr_test.py
---------------- attr_test.py
[root@cnsz92vl12951 dir]# chattr +a attr_test.py
[root@cnsz92vl12951 dir]# vi attr_test.py
"attr_test.py"
"attr_test.py" E212: Can't open file for writing
Press ENTER or type command to continue
lsattr(显示文件隐藏属性)
lsattr [-adR] 文件或目录
参数与选项:
基本使用-a:将隐藏文件的属性也显示出来
-d:如果接的是目录,仅列出目录本身的属性而非目录内的文件名
-R:连同子目录的数据也一并列出来
[root@cnsz92vl12951 dir]# lsattr -adR attr_test.py
-----a---------- attr_test.py
文件特殊权限:SUID、SGID、SBIT
Set UID (SUID)
文件权限除了r、w、x三个,看看下面这两个文件
s与t这两个权限的意义与系统的账号及系统的进程管理较为有关,后面会详细介绍。
s这个标志会出现在拥有者x权限上时,此时就被称为Set UID,简称为SUID的特殊权限。SUID对文件的限制于功能[root@cnsz92vl12951 dir]# ls -l /tmp/ ; ls -l /usr/bin/passwd
total 4
-rw-r--r-- 1 root root 26 Aug 9 20:44 osw.hb
drwx------ 3 root root 16 Mar 11 09:35 systemd-private-1828000e965d45a7801bef37bbbee106-chronyd.service-q0dVrX
drwx------ 3 root root 16 Jun 26 11:54 systemd-private-1828000e965d45a7801bef37bbbee106-mariadb.service-eaIxIg
-rwsr-xr-x 1 root root 27856 Apr 1 2020 /usr/bin/passwd
- SUID权限仅对二进制程序有效
- 执行者对该程序需要有x的可执行权限
- 本权限仅在执行该程序过程中有效(run-time)
- 执行者将具有该程序拥有者的权限
Set GID (SGID)
当s标志在文件拥有者的x权限上时,称为SGID。如下:
SGID有如下功能:[root@cnsz92vl12951 dir]# ls -l /usr/bin/locate
-rwx--s--x 1 root slocate 40520 Apr 11 2018 /usr/bin/locate
- SGID对二进制程序有用
- 执行者对该程序需要有x的可执行权限
- 执行者将具有该程序用户组的权限
- Sticky Bit (SBIT)
当t标志在文件其他组的x权限上时,称为SBIT,SBIT目前只针对目录有效,对文件已经没有效果。SBIT对目录的作用是:- 当用户对于此目录具有w、x权限,即具有写入的权限
- 当用户在目录下建立文件或目录时,仅有自己与root才有权力删除该文件
举例:用户甲对目录A具有用户组或其他人权限,并拥有该目录w的权限,这表示甲用户对该目录内任何人建立的目录或文件均可进行删除、更名、移动等操作。不过,如果将A目录加上SBIT的权限选项后,则甲只能针对自己建立的文件或目录进行删除、更名、移动等操作,而无法删除他人的文件
SUID/SGID/SBIT权限设置
4:SUID
2:SGID
1:SBIT
chmod [num]755 filename[root@cnsz92vl12951 dir]# lsattr attr_test.py
---------------- attr_test.py
[root@cnsz92vl12951 dir]# chmod 4755 attr_test.py
[root@cnsz92vl12951 dir]# ls -l attr_test.py
-rwsr-xr-x 1 root root 0 Aug 9 20:35 attr_test.py
观察文件类型file
file命令可以用来查询文件的基本信息,如属于ASCII或者是数据文件或二进制文件,有没有用到动态链接库等
[root@cnsz92vl12951 dir]# touch file_test.py
[root@cnsz92vl12951 dir]# vi file_test.py
[root@cnsz92vl12951 dir]# file file_test.py
file_test.py: ASCII text
命令与文件的查找
脚本文件的查找
which(查找【执行文件】)
which [-a] command
选项或参数:-a:将所有由PATH目录中可以找到的命令均列出,而不止第一个被找到的命令
基本使用 ``` [root@cnsz92vl12951 dir]# which ifconfig /sbin/ifconfig
[root@cnsz92vl12951 dir]# which which alias which=’alias | /usr/bin/which —tty-only —read-alias —show-dot —show-tilde’ /bin/alias /usr/bin/which
[root@cnsz92vl12951 dir]# which history /usr/bin/which: no history in (/sbin:/bin:/usr/sbin:/usr/bin)
[root@cnsz92vl12951 dir]# history —help bash: history: —: invalid option history: usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg…]
注意:which命令是根据【PATH】环境变量所规范的路径,查找执行文件的文件名,重点是找出执行文件而已,且which后面接的是完整的文件名。最后的history例子中,因为history是bash内置的命令,which从PATH内的目录找不到,所有出现这种情况。后面将介绍type命令(bash相关)
<a name="66a25d72"></a>
#### 文件的查找
- whereis(特定目录中查找文件)<br />选项和参数: <br />基本使用
-l:可以列出whereis会查询的几个主要目录 -b:只找binary格式文件 -m:只找说明文件manual路径下的文件 -s:只找source源文件 -u:查找不在上述三个项目当中的其他特殊文件
```
ipconfig:[root@cnsz92vl12951 dir]# whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
locate(输入文件名称)
locate [-ir] keypword
选项和参数:-i:忽略大小写的差异
-c:不输出文件名,仅计算找到的文件数量
-l:仅输出几行的意思,如:-l 5 输出5行
-S:输出locate所使用的数据文件的相关信息,包括该数据库记录的文件/目录数量等
-r:后面可接正则表达式
基本使用 ```shell [root@cnsz92vl12951 dir]# locate passwd -l 5 /etc/passwd /etc/passwd- /etc/pam.d/passwd /etc/security/opasswd /usr/bin/gpasswd
[root@cnsz92vl12951 dir]# locate -S Database /var/lib/mlocate/mlocate.db: 37,657 directories 264,760 files 19,600,837 bytes in file names 7,847,931 bytes used to store database
locate命令的限制:因为是由数据库查找,数据库的建立默认是每天执行一次,如果新建的文件,数据库还没来得及更新,则会找不到。<br />手动更新locate数据库(updatedb命令,一般需要数分钟)
```shell
[root@cnsz92vl12951 linux_basic]# ll
total 16
drwxr-xr-x 2 root root 6 Aug 6 10:33 dir
-rw-r--r-- 1 root root 0 Aug 6 10:33 dir.py
-rw-r--r-- 1 root root 6720 Aug 6 09:08 factory.py
d--x--x--x 2 william william 54 Aug 5 19:58 test
drwxrwxr-x 2 root root 6 Aug 6 10:47 test-dir
-rw-rw-r-- 1 root root 0 Aug 6 10:47 test-dir.py
-rw-r--r-- 1 root root 26 Aug 1 12:00 test-william.py
-rw-r--r-- 1 root root 15 Aug 9 19:40 william.py
[root@cnsz92vl12951 linux_basic]# touch shigl.py
[root@cnsz92vl12951 linux_basic]# locate shigl.py
[root@cnsz92vl12951 linux_basic]# updatedb
[root@cnsz92vl12951 linux_basic]# locate shigl.py
/app/linux_basic/shigl.py
- find
find [PATH] [option] [option]
选项与参数:
与时间有关的选项参数:-atime、-ctime与-mtime,以-mtime为例:
-mtime n:n为证书,意为在n天之前的[一天内]被修改过内容的文件
-mtime +n:列出在n天之前(不含n本身)被修改过内容的文件
-mtime -n:列出n天之内(含n本身)被修改过内容的文件
-newer file: file为一个存在的文件,列出此file还要新的文件
n值详细说明:
+4:代表大于等于5天前的文件
-4:代表小于等于4天内的文件
4:代表4-5那一天的文件
基本使用
# 列出过去24小时指定目录下修改过内容的文件
[root@cnsz92vl12951 linux_basic]# find ./ -mtime 0
./
./dir
./dir/attr_test.py
./dir/file_test.py
./william.py
./shigl.py
使用者或用户组名称有关的参数:
-uid n:n为数字,这个参数使用者的账号ID,也是UID
-gid n:n为数字,这个参数用户组的名称ID,也是GID
-user name:name为使用者账号名称
-group name:name为用户组名称
-nouser:查找文件的拥有者不在/etc/passwd中
-nogroup:查找文件的拥有用户组不存在/etc/group中
基本使用
[root@cnsz92vl12951 linux_basic]# find ./ -user william
./test
与文件权限和名称有关的参数:
-name filename:查找名称为filename的文件
-size [+-] SIZE:查找比SIZE大/小的文件,例如:-size +50k
-type TYPE:查找文件的类型为TYPE的,类型一般有:正规文件(f)、设备文件(b,c)、 目录(d)、链接文件(l)、socket(s)、FIFO(p)等属性
-perm mode:查找文件权限[刚好等于]mode权限的文件 如:-perm 0755
-perm -mode:查找文件权限[全部囊括]mode权限的文件 如:-perm -0755
-perm /mode:查找文件权限[包含任一]mode权限的文件 如:-perm /0755
基本使用
# find 查找目录 -name 文件名
[root@cnsz92vl12951 shigl]# find / -name passwd
/etc/passwd
/etc/pam.d/passwd
/usr/bin/passwd
/usr/share/bash-completion/completions/passwd
[root@cnsz92vl12951 linux_basic]# find -type d
.
./test
./dir
./test-dir
[root@cnsz92vl12951 linux_basic]# find -perm -0755
.
./dir
./test-dir
[root@cnsz92vl12951 linux_basic]# find -perm -755
.
./dir
./test-dir
[root@cnsz92vl12951 linux_basic]# find -perm /755
.
./test
./test/test_01.py
./test/test_02.py
./test/test.py
./test-william.py
./factory.py
./dir
./dir.py
./test-dir.py
./test-dir
./william.py
./shigl.py
find配合-exec参数执行
[root@cnsz92vl12951 linux_basic]# find /usr/bin/ /usr/sbin -perm /6000
/usr/bin/wall
/usr/bin/chage
/usr/bin/gpasswd
[root@cnsz92vl12951 linux_basic]# find /usr/bin/ /usr/sbin -perm /6000 -exec ls -l {} \;
-r-xr-sr-x. 1 root tty 15344 Jun 10 2014 /usr/bin/wall
-rwsr-xr-x 1 root root 73888 Aug 9 2019 /usr/bin/chage
-rwsr-xr-x 1 root root 78408 Aug 9 2019 /usr/bin/gpasswd