1.基础命令
(1)
grep root /etc/passwd > /opt/grep.txt
(2)
date -s "2023-12-12 15:20:54" > /opt/time.txt #这题考试的时候就不会 修改时间是date -s "日期(空格)时间【格式为 2023-12-12 15:20:54】
(3)
cd /tmp
mv test.txt /opt
mv test.txt rhel-test.txt
echo "Hello RHEL" >rhel-test.txt
(4)
[root@control memeda]# ls
memeda wenjian
[root@control memeda]# ls > /root/file-memeda.txt
[root@control memeda]# cat /root//file-memeda.txt
memeda
wenjian
(5)
[root@control memeda]# vim /etc/shadow
[root@control memeda]# cat /opt/passwd2
bin:*:18367:0:99999:7:::
daemon:*:18367:0:99999:7:::
adm:*:18367:0:99999:7:::
lp:*:18367:0:99999:7:::
2.用户管理
(1)
[root@control /]#useradd alice useradd bob &&useradd herry
(2)
[root@control /]# groupadd it -g 2023
(3)
[root@control /]# usermod alice -G it
#不会添加描述信息 也忘记在哪里打开用户信息
(4)
vim /etc/passwd- bin
#跟在gid uid后面的就是注释
(5)
把bob的最后一个改为/sbin/nologin
(6)
[root@control /]# su - bob
[bob@control ~]$ pwd
/home/bob
[bob@control ~]$ touch exexfile
[bob@control ~]$ ll
total 0
-rw-rw-r--. 1 bob bob 0 Dec 12 16:08 exexfile
[bob@control ~]$ chmod 555 exexfile
[bob@control ~]$ ll
total 0
-r-xr-xr-x. 1 bob bob 0 Dec 12 16:08 exexfile
3.文本处理工具
(1)
cat -n 10,40 /etc/passwd |grep system > /root/passwd3
(2)
vim /etc/sysconfig/network-scripts/ifcfg-ens160
(3)
[root@control ~]# sort -n -k 3 -t : /etc/passwd |head -n 20 |awk -F : '{print $3}' > /tmp/uid.txt
cat /tmp/uid.txt
0
1
2
3
4
5
6
7
8
11
12
14
29
32
42
48
59
70
72
74
(4)
[root@control ~]# tr 'a-z' 'A-Z' < /root/passwd3
15 SYSTEMD-COREDUMP:X:999:997:SYSTEMD CORE DUMPER:/:/SBIN/NOLOGIN
16 SYSTEMD-RESOLVE:X:193:193:SYSTEMD RESOLVER:/:/SBIN/NOLOGIN
39 FLATPAK:X:978:977:USER FOR FLATPAK SYSTEM HELPER:/:/SBIN/NOLOGIN
[root@control ~]# tr 'a-z' 'A-Z' < /root/passwd3 >/opt/capital.txt
[root@control ~]# cat /opt/capital.txt
15 SYSTEMD-COREDUMP:X:999:997:SYSTEMD CORE DUMPER:/:/SBIN/NOLOGIN
16 SYSTEMD-RESOLVE:X:193:193:SYSTEMD RESOLVER:/:/SBIN/NOLOGIN
39 FLATPAK:X:978:977:USER FOR FLATPAK SYSTEM HELPER:/:/SBIN/NOLOGIN
4.定时任务和查找
(1)
[root@localhost test]# crontab -u bob -e#然后再里面编写bob的定时任务
[root@localhost test]# crontab -u bob -l(查看定时任务)
15 9 1,25 * * echo studing
30 14 1,15 * * echo studing
45 19 1,15 * * echo studing
(第一次编写 格式错了 每个时间之间要空格 )
Do you want to retry the same edit?#这个报错就是你的时间格式写错了
(第二次编写 每个月的格式错了 并不是/1 而是*)
(第三次编写 成功)
crontab: installing new crontab
(2)
[root@localhost /]# find -perm 555 -user bob #权限 -perm 用户 -user
./proc/2476
./proc/2476/task
./proc/2476/task/2476
./proc/2476/task/2476/net
./proc/2476/task/2476/attr
./proc/2476/net
./proc/2476/attr
find: ‘./proc/2580/task/2580/fd/6’: No such file or directory
find: ‘./proc/2580/task/2580/fdinfo/6’: No such file or directory
find: ‘./proc/2580/fd/7’: No such file or directory
find: ‘./proc/2580/fdinfo/7’: No such file or directory
./home/bob/555
(3)
[root@localhost test]# find /test -name "*.txt" > /root/txt_files
[root@localhost test]# cat /root/txt_files
/test/1.txt
/test/2.txt
/test/3.txt
/test/4.txt
/test/5.txt
/test/6.txt
/test/7.txt
/test/8.txt
/test/9.txt
/test/10.txt
/test/{a-d}.txt
/test/[a-d].txt
/test/a-z.txt
5.系统相关策略
(1)
文件的权限和目录的权限并不是用同一个umask值
怎么区分呢
[root@localhost ~]# vim /home/alice/.bashrc
(2)
(3)
6.文件和储存
[root@localhost ~]# pvcreate /dev/nvme0n2p{1,2}
[root@localhost ~]# pvs
[root@localhost ~]# vgcreate vg /dev/nvme0n2p{1,2}
[root@localhost ~]# vgs
[root@localhost ~]# lvcreate -L 9G vg -n lv-vg
Logical volume "lv-vg" created.
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- <15.51g
swap rhel -wi-ao---- 4.00g
lv-vg vg -wi-a----- 9.00g
7.shell脚本
8.yum仓库配置
9.容器内容
12.配置ansible