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 /mnt mount: /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/bak mv: 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=local baseurl=file:///mnt enabled=1 gpgcheck=0
查看本地镜像源
[root@Centos7-111 yum.repos.d]# yum repolist all Loaded plugins: fastestmirror Determining fastest mirrors local | 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 status local local enabled: 447 repolist: 447
安装zip包
[root@Centos7-111 yum.repos.d]# [root@Centos7-111 yum.repos.d]# yum install -y zip Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package zip.x86_64 0:3.0-11.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================== Package Arch Version Repository Size ========================================================================== Installing: zip x86_64 3.0-11.el7 local 260 k Transaction Summary ========================================================================== Install 1 Package Total download size: 260 k Installed size: 796 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running 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 --permanent success [root@Centos7-111 ~]# firewall-cmd --list-port [root@Centos7-111 ~]# firewall-cmd --reload success [root@Centos7-111 ~]# firewall-cmd --list-port 80/tcp [root@Centos7-111 ~]# firewall-cmd --query-port=80/tcp yes3. 查找和替换文件
生成一个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/nologin4. 配置定时任务
[root@Centos7-111 ~]# crontab -l no crontab for root [root@Centos7-111 ~]# crontab -e no crontab for root - using an empty one crontab: installing new crontab [root@Centos7-111 ~]# crontab -l 35 * * * * ls [root@Centos7-111 ~]# date Sat Jan 22 19:29:53 CST 20225. 配置佛主保佑
编辑 /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 高级命令
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)