# 小文件
cat -n echo.sh 「 -n 行号 」
tac echo.sh 「 倒显 」
nl echo.sh 「 带行号 」
# 翻页
more /etc/services 「 空格 下页 & <C-b> 上页 backward & <C-f> 下页 forward & q 退出」
less /etc/services
/http 「 n 下个 & N 上个」
# 头部尾部
head -n 3 /etc/services 「 -n number 」
tail -n 3 /etc/services 「 尾3行 」
tail -f /etc/services 「 动态 」
tail -f /etc/services 「 service network restart 」
# 二进制文件
od -t c /bin/ls 「 -t 编码 」
strings /bin/ls
rm -fr *
alias ll 「 alias ll='ls -l --color=auto'」
# 创建文件
touch echo.sh 「 创建文件 & 更新时间戳 」
touch a b c 「 三个 」
ll | grep -v nginx
-rw-r--r--. 1 root root 0 Jun 29 10:30 a.txt
drwxr-xr-x. 2 root root 4096 Jun 29 10:30 b
# 权限过滤
umask 「 0022 & 777 -022 = 755 」
umask -S 「保留值 & u=rwx,g=rx,o=rx 」
# 隐藏文件属性
mkdir xx
mkdir xx/aa
chattr +a xx/ 「 只能增加 」
lsattr 「 文件属性 」
-----a-------e-- ./xx
touch xx/bb
touch xx/cc
ls xx/
lsattr xx/ 「 输出 」
-------------e-- xx/bb
-------------e-- xx/cc
-------------e-- xx/aa
rm -rf xx/bb 「 输出 & 不能删」
rm: cannot remove 'xx/bb': Operation not permitted
rm -rf xx/cc
rm: cannot remove 'xx/cc': Operation not permitted
touch xx/dd 「 可以增加 」
mkdir rhca
touch rhca/aa
chattr +i rhca/ 「 不能增删改 」
lsattr | grep -v nginx 「 输出 」
----i--------e-- ./rhca
touch rhca/bb 「 输出 」
touch: cannot touch 'rhca/bb': Permission denied
chattr -i rhca/ 「 去除 -i 属性 & 新建文件 」
touch rhca/bb
chattr +i rhca/
touch rhca/cc
touch: cannot touch 'rhca/cc': Permission denied
# suid、guid、Sticky
touch xx
ll xx 「 输出 & 622 」
-rw-r--r--. 1 root root 0 Jun 29 14:25 xx
chmod u+s xx
ll xx
-rwSr--r--. 1 root root 0 Jun 29 14:25 xx
rm -f xx
which passwd
/usr/bin/passwd
hostname 「 主机名 」
echo "abc `hostname`" 「 命令引用 」
echo "abc $(hostname)”
ls -l `which passwd`
-rwsr-xr-x. 1 root root 27832 Jun 10 2014 /usr/bin/passwd 「 suid & 他人等同 owner 权限,修改 /etc/shadow」
ls -l /etc/shadow
----------. 1 root root 1189 Jun 22 21:47 /etc/shadow
ls -l `which vim` = ls -l /bin/vim
-rwxr-xr-x. 1 root root 2294208 Oct 31 2018 /bin/vim
chmod u+s /bin/vim 「 suid & 普通用户使用vim可以修改root的文件 」
mkdir rhce
ls -ld rhce/
drwxr-xr-x. 2 root root 4096 Jun 29 15:39 rhce/
chgrp thomas rhce/
ls -ld rhce/
drwxr-xr-x. 2 root thomas4096 Jun 29 15:39 rhce/
touch rhce/aa
ls -l rhce/
-rw-r--r--. 1 root root0 Jun 29 15:45 aa
chmod g+s rhce/ 「 sgid & 子文件组继承 」
ls -ld rhce/
drwxr-sr-x. 2 root thomas 4096 Jun 29 15:45 rhce/
touch rhce/bb
ls -l rhce/bb
-rw-r--r--. 1 root thomas0 Jun 29 15:56 rhce/bb
rm -fr rhce/
mkdir rhce
chmod o+t rhce/ 「 t权限 & 其他人不能删除 」
ls -ld rhce/
drwxr-xr-t. 2 root root 4096 Jun 29 16:11 rhce/
chmod 4644 a.txt 「 suid」
chmod 2644 a.txt 「 guid」
chmod 1644 a.txt 「 t 」
file nginx-1.19.0.tar.gz