openEuler操作系统(练习1)

1、指定在每天凌晨4:00将该时间点之前的系统日志信息(/var/log/messages)备份到目录下(/backup),备份后日志文件名显示格式(logfileYY-MM-DD-HH-MM)

①查看crontab工作调度对应的系统服务状态

[root@RHCE11 ~]# ll /var/spool/cron/
总用量 4
-rw-------. 1 root root 62 11月 19 21:59 root
[root@RHCE11 ~]# systemctl status crond
● crond.service - Command Scheduler
     Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-11-20 18:28:41 CST; 1h 41min ago
   Main PID: 917 (crond)
      Tasks: 1 (limit: 21384)
     Memory: 3.6M
     CGroup: /system.slice/crond.service
             └─ 917 /usr/sbin/crond -n

11月 20 18:28:41 RHCE11.18 crond[917]: (CRON) bad minute (/etc/crontab)
11月 20 19:01:01 RHCE11.18 CROND[1824]: (root) CMD (run-parts /etc/cron.hourly)
11月 20 19:01:01 RHCE11.18 anacron[1837]: Anacron started on 2023-11-20
11月 20 19:01:01 RHCE11.18 anacron[1837]: Will run job `cron.daily' in 36 min.
11月 20 19:01:01 RHCE11.18 anacron[1837]: Jobs will be executed sequentially
11月 20 19:37:01 RHCE11.18 anacron[1837]: Job `cron.daily' started
11月 20 19:37:01 RHCE11.18 anacron[1837]: Job `cron.daily' terminated
11月 20 19:37:01 RHCE11.18 anacron[1837]: Normal exit (1 job run)
11月 20 20:01:01 RHCE11.18 CROND[2338]: (root) CMD (run-parts /etc/cron.hourly)
11月 20 20:03:01 RHCE11.18 crond[917]: (*system*) RELOAD (/etc/crontab)

②crontab工作的日志文件

[root@RHCE11 ~]# ll /var/log/cron
-rw-------. 1 root root 18877 11月 20 20:03 /var/log/cron

③用户定义计划任务的文件所在目录

[root@RHCE11 ~]# ll /var/spool/cron/
总用量 4
-rw-------. 1 root root 62 11月 19 21:59 root

④本题答案

[root@RHCE11 ~]# vim /etc/crontab
[root@RHCE11 ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
0 4 * * * root cp -r /var/log/messages /backup/logfile$(date +\%y-\%m-\%d-\%H-\%M)
[root@RHCE11 ~]# crontab -l
0 4 * * * root cp -r /var/log/messages /backup/logfile$(date +\%y-\%m-\%d-\%H-\%M)

2、配置ssh免密登陆:客户端主机通过redhat用户基于秘钥验证方式进行远程连接服务器的root用户

服务端的配置:

#装包
[root@RHCE11 ~]# dnf install openssh-server -y
#修改配置文件(不用修改)
#服务端收到公钥的文件
[root@RHCE11 ~]# ll /root/.ssh
总用量 20
-rw-------. 1 root root 1145 11月 22 17:59 authorized_keys
#添加redhat用户
[root@RHCE11 ~]# useradd redhat

客户端的配置:

#检测客户端是否能登陆root账号
[redhat@rhce ~]$ ssh root@192.168.126.132
#生成密钥对
[redhat@RHCE11 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/redhat/.ssh/id_rsa):
Created directory '/home/redhat/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/redhat/.ssh/id_rsa
Your public key has been saved in /home/redhat/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:EpDG4Ab7U9T6LGxTz/iuPIDUMgEjsUGdzH1McYIqkl4 redhat@RHCE11
The key's randomart image is:
+---[RSA 3072]----+
|O+=o=o++..       |
|.B.*++.oo        |
|o.o+o.o          |
|o++Eo ..         |
|o.== +.+S        |
| ...* +.o        |
|   . + .         |
|     .. .        |
|      o+.        |
+----[SHA256]-----+
[redhat@RHCE11 ~]$ ll /home/redhat/.ssh
总用量 8
-rw-------. 1 redhat redhat 2602 12月  2 16:45 id_rsa
-rw-r--r--. 1 redhat redhat  567 12月  2 16:45 id_rsa.pub
#将客户端的公钥传给服务端(这是一种传的指令scp root@192.168.126.132 :/root/.ssh)
[redhat@RHCE11 ~]$ ssh-copy-id root@192.168.126.132
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/redhat/.ssh/id_rsa.pub"
The authenticity of host '192.168.126.132 (192.168.126.132)' can't be established.
ED25519 key fingerprint is SHA256:wPaAqee8b8fHPp8P8N8nBfjAagiU+WcC1euY08mx7Hw.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
[redhat@RHCE11 ~]$ ssh root@192.168.126.132

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Last login: Sat Dec  2 16:43:59 2023 from 192.168.126.1


Welcome to 5.10.0-153.12.0.92.oe2203sp2.x86_64

System information as of time:  2023年 12月 02日 星期六 16:46:49 CST

System load:    0.01
Processes:      148
Memory used:    5.8%
Swap used:      0%
Usage On:       22%
IP address:     192.168.126.132
Users online:   2

3、搭建一个web网站,网站显示hello world内容

#装包
[root@rhce ~]# dnf install nginx -y
#修改配置文件(本次实验不需要)
[root@rhce ~]# vim /etc/nginx/nginx.conf
#重启服务
[root@rhce ~]# systemctl restart nginx
#关闭防火墙
[root@rhce ~]# systemctl restart firewalld
#关闭selinux
[root@rhce ~]# setenforce 0
#修改html文件
[root@rhce html]# vim index.html
hello world
[root@rhce html]# curl localhost
hello world
[root@rhce html]# curl 192.168.126.132
hello world
[root@rhce html]# curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.21.5
Date: Wed, 22 Nov 2023 11:53:40 GMT
Content-Type: text/html
Content-Length: 12
Last-Modified: Wed, 22 Nov 2023 11:51:20 GMT
Connection: keep-alive
ETag: "655deb38-c"
Accept-Ranges: bytes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值