1. 使⽤ls查看/etc/⽬录下所有的⽂件信息
[root@localhost ~]# ls /etc/
adjtime hosts rc1.d
aliases hosts.allow rc2.d
aliases.db hosts.deny rc3.d
alternatives init.d rc4.d
anacrontab inittab rc5.d
asound.conf inputrc rc6.d
audisp iproute2 rc.d
audit issue rc.local
bash_completion.d issue.net redhat-release
bashrc kdump.conf resolv.conf
binfmt.d kernel resolv.conf.save
centos-release krb5.conf rpc
centos-release-upstream krb5.conf.d rpm
chkconfig.d ld.so.cache rsyslog.conf
chrony.conf ld.so.conf rsyslog.d
chrony.keys ld.so.conf.d rwtab
cron.d libaudit.conf rwtab.d
cron.daily libnl sasl2
cron.deny libuser.conf securetty
cron.hourly locale.conf security
cron.monthly localtime selinux
crontab login.defs services
cron.weekly logrotate.conf sestatus.conf
crypttab logrotate.d shadow
csh.cshrc lvm shadow-
csh.login machine-id shells
dbus-1 magic skel
default makedumpfile.conf.sample ssh
depmod.d man_db.conf ssl
dhcp mke2fs.conf statetab
DIR_COLORS modprobe.d statetab.d
DIR_COLORS.256color modules-load.d subgid
DIR_COLORS.lightbgcolor motd subuid
dracut.conf mtab sudo.conf
dracut.conf.d my.cnf sudoers
e2fsck.conf my.cnf.d sudoers.d
environment NetworkManager sudo-ldap.conf
ethertypes networks sysconfig
exports nsswitch.conf sysctl.conf
favicon.png nsswitch.conf.bak sysctl.d
filesystems openldap systemd
firewalld opt system-release
fonts os-release system-release-cpe
fstab pam.d terminfo
fuse.conf passwd tmpfiles.d
gcrypt passwd- tuned
GeoIP.conf pkcs11 udev
GeoIP.conf.default pki vconsole.conf
gnupg plymouth vimrc
GREP_COLORS pm virc
groff polkit-1 vmware-tools
group popt.d vsftpd
group- ppp wgetrc
grub2.cfg prelink.conf.d wpa_supplicant
grub.d printcap X11
gshadow profile xdg
gshadow- profile.d xinetd.d
gss protocols yum
host.conf python yum.conf
hostname rc0.d yum.repos.d
2. 使⽤ls查看/etc/⽬录下名包含“a”字⺟的⽂件或者⽬录信息
[root@localhost ~]# ls /etc/*a*
/etc/adjtime /etc/gshadow- /etc/os-release
/etc/aliases /etc/hostname /etc/passwd
/etc/aliases.db /etc/hosts.allow /etc/passwd-
/etc/anacrontab /etc/inittab /etc/printcap
/etc/asound.conf /etc/ld.so.cache /etc/rc.local
/etc/bashrc /etc/libaudit.conf /etc/redhat-release
/etc/centos-release /etc/locale.conf /etc/resolv.conf.save
/etc/centos-release-upstream /etc/localtime /etc/rwtab
/etc/crontab /etc/logrotate.conf /etc/sestatus.conf
/etc/crypttab /etc/machine-id /etc/shadow
/etc/dracut.conf /etc/magic /etc/shadow-
/etc/favicon.png /etc/makedumpfile.conf.sample /etc/statetab
/etc/fstab /etc/man_db.conf /etc/sudo-ldap.conf
/etc/GeoIP.conf.default /etc/mtab /etc/system-release
/etc/gshadow /etc/nsswitch.conf.bak /etc/system-release-cpe
/etc/alternatives:
ld libnssckbi.so.x86_64
/etc/audisp:
audispd.conf plugins.d
/etc/audit:
auditd.conf audit.rules audit-stop.rules rules.d
/etc/bash_completion.d:
iprutils redefine_filedir
/etc/cron.daily:
logrotate man-db.cron
/etc/default:
grub nss useradd
/etc/dracut.conf.d:
/etc/firewalld:
firewalld.conf helpers icmptypes ipsets lockdown-whitelist.xml services zones
/etc/logrotate.d:
bootlog chrony mysql syslog vsftpd wpa_supplicant yum
/etc/modules-load.d:
/etc/NetworkManager:
conf.d dnsmasq.d NetworkManager.conf
dispatcher.d dnsmasq-shared.d system-connections
/etc/openldap:
certs ldap.conf
/etc/pam.d:
chfn passwd runuser-l system-auth
chsh password-auth smartcard-auth system-auth-ac
config-util password-auth-ac smartcard-auth-ac systemd-user
crond polkit-1 sshd vlock
fingerprint-auth postlogin su vmtoolsd
fingerprint-auth-ac postlogin-ac sudo vsftpd
login remote sudo-i
other runuser su-l
/etc/rwtab.d:
logrotate
/etc/sasl2:
/etc/statetab.d:
/etc/vmware-tools:
GuestProxyData poweron-vm-default statechange.subr vgauth.conf
guestproxy-ssl.conf resume-vm-default suspend-vm-default
poweroff-vm-default scripts vgauth
/etc/wpa_supplicant:
wpa_supplicant.conf
3. 使⽤ls查看/etc/⽬录下以".conf"结尾的⽂件信息
[root@localhost ~]# ls /etc/*.conf
/etc/asound.conf /etc/kdump.conf /etc/man_db.conf /etc/sudo-ldap.conf
/etc/chrony.conf /etc/krb5.conf /etc/mke2fs.conf /etc/sysctl.conf
/etc/dracut.conf /etc/ld.so.conf /etc/nsswitch.conf /etc/vconsole.conf
/etc/e2fsck.conf /etc/libaudit.conf /etc/resolv.conf /etc/yum.conf
/etc/fuse.conf /etc/libuser.conf /etc/rsyslog.conf
/etc/GeoIP.conf /etc/locale.conf /etc/sestatus.conf
/etc/host.conf /etc/logrotate.conf /etc/sudo.conf
4. 使⽤ls查看/etc/⽬录中以"y"字⺟开头的⽂件信息
[root@localhost ~]# ls /etc/y*
/etc/yum.conf
/etc/yum:
fssnap.d pluginconf.d protected.d vars version-groups.conf
/etc/yum.repos.d:
tgsy.repo
5. find查找/var/⽬录中以“.log”⽂件
[root@localhost ~]# find /var/ -name "*.log" -type f
/var/log/tuned/tuned.log
/var/log/audit/audit.log
/var/log/anaconda/anaconda.log
/var/log/anaconda/X.log
/var/log/anaconda/program.log
/var/log/anaconda/packaging.log
/var/log/anaconda/storage.log
/var/log/anaconda/ifcfg.log
/var/log/anaconda/ks-script-hPtrDE.log
/var/log/anaconda/ks-script-wn28ax.log
/var/log/anaconda/journal.log
/var/log/boot.log
/var/log/vmware-vmsvc.log
/var/log/yum.log
/var/log/mysqld.log
6. 在opt⽬录下创建test⽬录
[root@localhost ~]# mkdir /opt/test
7. 在test⽬录中创建abc.txt,def.txt.ghi.txt,xxx.txt.yyy.txt五个⽂件
[root@localhost ~]# mkdir /opt/test
[root@localhost ~]# cd /opt/test
[root@localhost test]# touch abc.txt def.txt ghi.txt xxx.txt yyy.txt
8. 修改以上5个⽂件的最后修改时间分别为15,14,13,12,11,10⽇
[root@localhost test]# touch abc.txt def.txt ghi.txt xxx.txt yyy.txt
[root@localhost test]# touch abc.txt -m -d "2024-7-15 00:00"
[root@localhost test]# touch def.txt -m -d "2024-7-14 00:00"
[root@localhost test]# touch ghi.txt -m -d "2024-7-13 00:00"
[root@localhost test]# touch xxx.txt -m -d "2024-7-12 00:00"
[root@localhost test]# touch yyy.txt -m -d "2024-7-11 00:00"
9. 在test⽬录下创建a⽬录
[root@localhost test]# mkdir a
10. 将以上5个⽂件复制⼀份到a⽬录中
[root@localhost test]# cp abc.txt a
[root@localhost test]# cp def.txt a
[root@localhost test]# cp ghi.txt a
[root@localhost test]# cp xxx.txt a
[root@localhost test]# cp yyy.txt a
11. 将a⽬录⽂件做成bak.tar.gz⽂件保存到家⽬录中
[root@localhost test]# cd /home/
[root@localhost home]# tar -zcvf bak.tar.gz /opt/test/a
tar: 从成员名中删除开头的“/”
/opt/test/a/
/opt/test/a/abc.txt
/opt/test/a/def.txt
/opt/test/a/ghi.txt
/opt/test/a/xxx.txt
/opt/test/a/yyy.txt
12. 使⽤find删除test⽬录下3天前的⽂件
[root@localhost home]# find /opt/test/ -mtime +3 | xargs rm -rf
13. find删除opt⽬录下3天内的⽂件
[root@localhost home]# find /opt/* -mtime -3 -exec rm -rf {} \;
14. find删除正好第三天的⽂件
[root@localhost home]# find /opt/test -mtime 3 -exec rm -rf {} \;
15. 将/opt/test/a⽬录中的⽂件复⼀份到/opt/test/⽬录下
[root@localhost ~]# cp /opt/test/a/* /opt/test
16. 创建⽬录/opt/test0
[root@localhost ~]# mkdir /opt/test0
17. 在/opt/test0/⽬录中创建三个⽂件 a.mp4(5M),b.mp4(20M),c.mp4(80M)
[root@localhost ~]# dd if=/dev/zero of=a.mp4 bs=5M count=1
记录了1+0 的读入
记录了1+0 的写出
5242880字节(5.2 MB)已复制,0.0195403 秒,268 MB/秒
[root@localhost ~]# dd if=/dev/zero of=b.mp4 bs=20M count=1
记录了1+0 的读入
记录了1+0 的写出
20971520字节(21 MB)已复制,0.092686 秒,226 MB/秒
[root@localhost ~]# dd if=/dev/zero of=c.mp4 bs=80M count=1
记录了1+0 的读入
记录了1+0 的写出
83886080字节(84 MB)已复制,0.280751 秒,299 MB/秒
18. 创建⽬录/opt/test0/b/
[root@localhost ~]# mkdir /opt/test0/b/
19. 将/op t/test0/中的⽂件复制⼀份/opt/test0/b/⽬录中
[root@localhost ~]# cp /opt/test0/* /opt/test0/b
20. find查询/opt/test0/⽬录中⽂件⼤于20M的,并删除
[root@localhost ~]# find /opt/test0/ -size +20M -exec rm -rf {} \;
21. find查询/opt/test0/⽬录中⽂件⼩于20M的⽂件并删除
[root@localhost ~]# find /opt/test0/ -size -20M -exec rm -rf {} \;
22. find查找/opt/test0/⽬录中⽂件size为20M的⽂件并删除
[root@localhost ~]# find /opt/test0/ -size 20M -exec rm -rf {} \;
23. /opt/test0/b中的⽂件复制⼀份到/opt/test0中
[root@localhost ~]# cp /opt/test0/b/* /opt/test0
24. 打开新的虚拟主机
25. 将家⽬录中的bak.tar.gz⽂件上传到新主机的/opt⽬录中
[root@localhost ~]# scp /home/bak.tar.gz [email protected]:/opt/
[email protected]'s password:
26. 将新主机的/e tc/skel/⽬录下载到 当前主机的/opt⽬录中
[root@localhost ~]# scp -r [email protected]:/etc/skel/ /opt/
[email protected]'s password:
.bash_logout 100% 18 19.3KB/s 00:00
.bash_profile 100% 193 241.4KB/s 00:00
.bashrc 100% 231 343.7KB/s 00:00
notice.text 100% 56 97.9KB/s 00:00
27. 设置计划任务,每周3将/e tc/yum.repos.d/⽬录下的.repo⽂件压缩保存到tmp,在⽂件 名中添加时间戳
[root@localhost ~]# crontab -e
0 0 * * 3 /usr/bin/tar -zcvf /tmp/etc_$(date "+\%Y\%m\%d\%H\%M\%S").tar.gz /etc/yum.re
pos.d/*.repo
标签:练习题,7.15,etc,test,conf,opt,root,localhost
From: https://blog.csdn.net/weixin_68468644/article/details/140472623