https://luciferliu.blog.csdn.net/article/details/122393279
这里写自定义目录标题第三天:Linux 高级命令
学习收获学习目标课后作业
1.配置本地YUM源,并安装zip软件2、配置防火墙3、查找和替换文件4、配置定时任务5、配置佛主保佑 相关链接 第三天:Linux 高级命令 学习收获
今天学习《每日一练:三天入门Linux系统》第三天课程:Linux 高级命令,赶紧把作业做起来!
三天LInux学习很快就结束了,非常感谢老师把命令按分类整理的这么好,Linux 命令是工作必备技能,经过实操才能更好掌握。老师的课程不错,后续有人需要也会推荐~~
学习目标Linux 高级命令,版本CentOS 7.9
课后作业 1.配置本地YUM源,并安装zip软件 1.本地光驱挂载ISO安装包
手动设置yum源文件
[root@Centos7-111 ~]# mount /dev/cdrom /mntmount: /dev/sr0 is write-protected, mounting read-only[root@Centos7-111 ~]# mkdir /etc/yum.repos.d/bak[root@Centos7-111 ~]# mv /etc/yum.repos.d/* /etc/yum.repos.d/bakmv: cannot move ‘/etc/yum.repos.d/bak’ to a subdirectory of itself, ‘/etc/yum.repos.d/bak/bak’[root@Centos7-111 ~]# {> echo "[local]"> echo "name=local"> echo "baseurl=file:///mnt"> echo "enabled=1"> echo "gpgcheck=0"> } >/etc/yum.repos.d/local.repo[root@Centos7-111 ~]# cd /etc/yum.repos.d/[root@Centos7-111 yum.repos.d]# cat local.repo [local]name=localbaseurl=file:///mntenabled=1gpgcheck=0
查看本地镜像源
[root@Centos7-111 yum.repos.d]# yum repolist allLoaded plugins: fastestmirrorDetermining fastest mirrorslocal | 3.6 kB 00:00 (1/2): local/group_gz | 3.5 kB 00:00 (2/2): local/primary_db | 832 kB 00:00 repo id repo name statuslocal local enabled: 447repolist: 447
安装zip包
[root@Centos7-111 yum.repos.d]# [root@Centos7-111 yum.repos.d]# yum install -y zipLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package zip.x86_64 0:3.0-11.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved========================================================================== Package Arch Version Repository Size==========================================================================Installing: zip x86_64 3.0-11.el7 local 260 kTransaction Summary==========================================================================Install 1 PackageTotal download size: 260 kInstalled size: 796 kDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : zip-3.0-11.el7.x86_64 1/1 Verifying : zip-3.0-11.el7.x86_64 1/1 Installed: zip.x86_64 0:3.0-11.el7 Complete!
安装成功
2、配置防火墙查询防火墙开启端口和状态
[root@Centos7-111 ~]# firewall-cmd --list-port[root@Centos7-111 ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-01-22 14:43:35 CST; 3h 53min ago Docs: man:firewalld(1) Main PID: 661 (firewalld) CGroup: /system.slice/firewalld.service └─661 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --no...Jan 22 14:43:34 Centos7-111 systemd[1]: Starting firewalld - dynamic f....Jan 22 14:43:35 Centos7-111 systemd[1]: Started firewalld - dynamic fi....Jan 22 14:43:35 Centos7-111 firewalld[661]: WARNING: AllowZoneDrifting ...Hint: Some lines were ellipsized, use -l to show in full.···
配置80端口,然后重启防火墙后,查询80端口已设置
···[root@Centos7-111 ~]# firewall-cmd --zone=public --add-port=80/tcp --permanentsuccess[root@Centos7-111 ~]# firewall-cmd --list-port[root@Centos7-111 ~]# firewall-cmd --reloadsuccess[root@Centos7-111 ~]# firewall-cmd --list-port80/tcp[root@Centos7-111 ~]# firewall-cmd --query-port=80/tcpyes
3、查找和替换文件生成一个test.txt,然后查找 ftp 的内容
[root@Centos7-111 ~]# cat /etc/passwd > /tmp/test.txt[root@Centos7-111 ~]# find / -name test.txt/tmp/test.txt[root@Centos7-111 ~]# grep "ftp" /tmp/test.txt ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin[root@Centos7-111 ~]#
替换内容,将一行加上备注 #
[root@Centos7-111 ~]# grep "nobody" /tmp/test.txt nobody:x:99:99:Nobody:/:/sbin/nologin[root@Centos7-111 ~]# sed -i 's/nobody/#nobody/g' /tmp/test.txt [root@Centos7-111 ~]# grep "nobody" /tmp/test.txt #nobody:x:99:99:Nobody:/:/sbin/nologin
4、配置定时任务[root@Centos7-111 ~]# crontab -lno crontab for root[root@Centos7-111 ~]# crontab -eno crontab for root - using an empty onecrontab: installing new crontab[root@Centos7-111 ~]# crontab -l35 * * * * ls[root@Centos7-111 ~]# dateSat Jan 22 19:29:53 CST 2022
5、配置佛主保佑 编辑 /etc/motd
···
[root@Centos7-111 ~]# vi /etc/motd
_ooOoo_ o8888888o 88" 、"88 (| -_- |) O = /O ____/`---'____ .' \| |// `. / \||| : |||// / _||||| -:- |||||- | | \ - /// | | | _| ''---/'' | | .-__ `-` ___/-、/ ___`、.' /--.-- `、、__ ."" '< `.____<|>_/___.' >'"". | | : `- `.;` _ /`;.`/ - ` : | | `-、 _ __ /__ _/ .-` / /
======-.____-._/__.-____.-'=======—=’
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
佛祖保佑 永无BUG
···
再次连接到服务器,真的显示佛祖保佑了
第3天作业真多,终于完成了,可以休息一会了~~~
三天打卡全部完成,内容很好,感谢版主!!
相关链接 [1] 活动介绍:http://t.csdn.cn/d3wNw
[2] 学习内容:三天入门Linux系统
[3] 第三天:Linux 高级命令