1、虚拟机地址
192.168.75.128/24
2、获取当前时间
[root@chenhaoze ~]# date
Sat Jan 11 16:55:42 CST 2025
3、修改时间
[root@chenhaoze ~]# date -s "2023 - 01 - 01 12:00:00"
Sun Jan 1 12:00:00 CST 2023
4、切换目录和查看目录
[root@chenhaoze ~]# cd/root/room
-bash: cd/root/room: No such file or directory
[root@chenhaoze ~]# ls
222 4.txt 8.txt.gz Music Videos anaconda-ks.cfg yasuo3.zip
'222^C' 444 Desktop Pictures a.txt error.txt zhengque.txt
3.txt 555 Documents Public a_hard.txt file.txt
333 7.txt Downloads Templates aaa ip.log3
5、打开当前的路径
[root@chenhaoze ~]# pwd
/root
6、创建
[root@chenhaoze ~]# # mkdir -p /root/dir1/
[root@chenhaoze ~]# ls
222 4.txt 8.txt.gz Music Videos anaconda-ks.cfg ip.log
'222^C' 444 Desktop Pictures a.txt dir1 ly
3.txt 555 Documents Public a_hard.txt error.txt yasuo3.zip
333 7.txt Downloads Templates aaa file.txt zhengque.txt
[root@chenhaoze ~]# mkdir -p /root/dir2
[root@chenhaoze ~]# ls
222 444 Documents Templates anaconda-ks.cfg ip.log
'222^C' 555 Downloads Videos dir1 ly
3.txt 7.txt Music a.txt dir2 yasuo3.zip
333 8.txt.gz Pictures a_hard.txt error.txt zhengque.txt
4.txt Desktop Public aaa file.txt
7、在/root下创建guazai1、guazai2、guazai3…一直到guazai10目录
[root@chenhaoze ~]# for i in {1..10}; do mkdir /root/guazai$i; done
[root@chenhaoze ~]# ls
222 555 Music a_hard.txt file.txt guazai5 ly
'222^C' 7.txt Pictures aaa guazai1 guazai6 shadow
3.txt 8.txt.gz Public anaconda-ks.cfg guazai10 guazai7 yasuo3.zip
333 Desktop Templates dir1 guazai2 guazai8 ys.tar.gz
4.txt Documents Videos dir2 guazai3 guazai9 zhengque.txt
444 Downloads a.txt error.txt guazai4 ip.log
8、删除
[root@chenhaoze ~]# rm -r /root/dir1/dir2
rm: remove directory '/root/dir1/dir2'? y
9、创建一个以自己的名字命名的文件
[root@chenhaoze ~]# touch ./ly
10、查看/etc/passwd文件的内容,并过滤出包含root的行
[root@chenhaoze ~]# grep 'root' /ect/passwd
11、使用echo
命令输出"Hello, World!"到屏幕上
[root@chenhaoze ~]# echo "Hello,World!"
Hello,World!
12、提取/etc/passwd第一列的内容
[root@chenhaoze ~]# cut -d':' -f1 /etc/passwd
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
tss
systemd-coredump
dbus
polkitd
avahi
colord
rtkit
pipewire
clevis
sssd
geoclue
flatpak
setroubleshoot
libstoragemgmt
gdm
cockpit-wsinstance
gnome-initial-setup
sshd
chrony
dnsmasq
tcpdump
redhat
13、为/root/anaconda-ks.cfg 文件创建软链接到/下并命名为a.cfg
[root@chenhaoze ~]# ln -s /root/anaconda-ks.cfg /a.cfg
14、复制/etc/shadow文件到/root下
[root@chenhaoze ~]# cp /etc/shadow /root/
[root@chenhaoze ~]# ls
222 444 Documents Templates anaconda-ks.cfg ip.log
'222^C' 555 Downloads Videos dir1 ly
3.txt 7.txt Music a.txt dir2 shadow
333 8.txt.gz Pictures a_hard.txt error.txt yasuo3.zip
4.txt Desktop Public aaa file.txt zhengque.txt
15、查找以repo结尾的文件
[root@chenhaoze ~]# find / -type f -name '*repo'
/run/media/root/RHEL-9-5-0-BaseOS-x86_64/media.repo
/etc/yum.repos.d/redhat.repo
/var/lib/rhsm/repo_server_val/redhat.repo
16、把/etc/gshadow 和/root/home打包压缩为/root/ys.tar.gz
[root@chenhaoze ~]# tar -czf /root/ys.tar.gz /etc/gshadow /root/home
tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets
tar: /root/home: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors