本文为2025年新疆职业院校技能大赛“统信杯”信创服务应用赛项全模块解析,这个比赛属于运维类比赛,考的都是一些运维类的知识,有需要的来看看吧
模块一:信创桌面操作系统运维
1.创建一个新用户并设置密码:
- 创建一个名为testuser的新用户。
sudo useradd testuser
- 使用命令为testuser设置密码,密码为uos123。
echo “testuser:uos123” | sudo chpasswd
2.修改用户权限:
- 将testuser添加到sudo组(如果适用),以便其能够执行管理任务。
sudo usermod -aG sudo testuser
- 检查修改是否成功,尝试使用sudo命令。
sudo -u testuser sudo -l
或者
sudo -u testuser sudo whoami
3.文件与目录管理:
- 创建一个名为project的目录。
mkdir project
ls -l | grep project
- 在project目录中创建一个名为file1.txt的空文件。
touch project/file1.txt ls -l project/
- 将file1.txt复制到/tmp目录下,并重命名为file2.txt。
cp project/file1.txt /tmp/file2.txt
ls -l /tmp | grep file2.txt
- 删除/tmp/file2.txt文件。
rm /tmp/file2.txt
4.查找文件:
- 使用find命令在根目录下查找名为passwd的文件。
sudo find / -name passwd -type f
- 使用grep命令在/etc/passwd文件中查找包含root的行。
grep ‘root’ /etc/passwd
5.配置静态IP地址:
- 修改网络接口配置文件,设置静态IP地址、子网掩码、和DNS服务器。
sudo vim /etc/NetworkManager/system-connections/有线连
接.nmconnection
- 重启网络服务使配置生效。
sudo systemctl restart networking
(有互联网的情况下) |
6.使用包管理器安装软件:
- 在基于UOS系统,安装nginx。
sudo apt install nginx -y
验证一下:
nginx -v
- 更新和升级系统:在UOS系统上,更新软件包列表并升级所有已安装的软件包。
sudo apt update && sudo apt upgrade -y
- 卸载软件:卸载之前安装的nginx软件。
sudo apt remove nginx -y
7.配置系统的crontab定时任务,每天凌晨2点自动备份/etc
目录到/backup/etc_backup_$(date+\%Y\%m\%d).tar.gz。
cd /
mkdir /backup
sudo crontab -e
0 2 * * * /bin/tar -czf
/backup/etc_backup_$(date+\%Y%m\%d).tar.gz /etc
8.请按照以下要求配置Linux系统,确保ssh服务在系统启动时自动运行,并且这些设置适用于传统的运行级别2、3、4、
5 sudo systemctl enable ssh
runlevel(运行级别需要确认)
9.文件与目录管理
- 创建一个新的目录,并在其中创建一个文件:uostest 。
mkdir newdir && touch newdir/uostest ls -l newdir/uostest
- 使用tar命令压缩和解压缩文件。
tar -czvf uostest.tar.gz newdir/uostest tar -xzvf uostest.tar.gz
10.SSH服务配置
- 修改SSH服务的配置文件,禁止root用户通过SSH登录。
sudo vim /etc/ssh/sshd_config
- 重启SSH服务,使配置生效。
sudo systemctl restart ssh
11.使用命令查看磁盘I/0性能。
vmstat
12.设置NTP时间同步。(1)安装ntpdate sudo apt install ntpdate
- 使用ntpdate同步cn.pool.ntp.org时间服务器
sudo systemctl stop systemd-timesyncd.service
2>/dev/null sudo ntpdate cn.pool.ntp.org
- 把输出的结果保存在/opt/date.txt
sudo ntpdate cn.pool.ntp.org | sudo tee
/opt/date.txt cat /opt/date.txt
模块二:信创服务器操作系统服务部署注:标记黄色的为需要确认的内容
1.ssh按照以下要求配置ssh服务:
- 宿主机可以使用root用户免密登录Server1和Server2
题目要求使用root用户实现免密登录,但是root在uos安装的时候没有设置root密码,所以需要使用sudo passwd root命令为 root设置密码
为宿主机的root用户生成ssh密钥对
ssh-keygen -t rsa -N “” -f ~/.ssh/id_rsa
ssh-copy-id root@Server1
验证成功
ssh root@Server1
注:Server2同理,这里不再演示
- Server1和Server2之间可通过root用户互相免密登录在Server1和Server2上生成密钥并互相分发注:需要在Server1和Server2上进行分别配置,相互分发的意思是在Server1上可以免密登录Server2,在Server2上可以免密登录Server1
# Server1 ssh-keygen -t rsa -N “” -f ~/.ssh/id_rsa ssh-copy-id root@Server2
注:Server2同样的配置,不再演示了
2.配置防火墙:
你有两台服务器,Server1和Server2,它们运行着Uos操作系统。为了确保服务器的安全性,你需要配置UFW防火墙。然而
,你还需要确保特定的服务能够从外部访问。这些服务包括 SSH(端口22)、HTTP(端口80)、HTTPS(端口443)以及MySQL( 端口3306)
注:这里是配置UFW防火墙,但是UFW无法安装,yum没内容,如果有,用UFW,如果没有,还是用firewalld吧: systemctl status firewalld.service
firewall-cmd –zone=public –add-port=22/tcp -permanent firewall-cmd –zone=public –add-port=80/tcp -permanent firewall-cmd –zone=public –add-port=443/tcp -permanent firewall-cmd –zone=public –add-port=3306/tcp -permanent
或者
firewall-cmd –zone=public –addport={22,80,443,3306}/tcp –permanent
都可以
或
firewall-cmd –reload
注1:Server2同样需要配置注2:我猜测裁判可能会使用firewall-cmd –list-all验证
3.在Server1上使用Apache配置基于端口的web虚拟主机,并实现下列要求:(解决uos.html文件问题和下载途径问题)
(1)虚拟主机监听的端口为9999
systemctl status httpd yum -y install httpd
验证安装情况,查看一下httpd版本
httpd -v
echo “Listen 9999” | tee -a
/etc/httpd/conf/httpd.conf
或者
vim /etc/httpd/conf/httpd.conf
或
注:用tee命令是追加到httpd.conf文件最后的,为了方便截图建议使用第二种,直接vim编辑
- 设置DocumentRoot为/var/www/uos mkdir /var/www/uos
vim /etc/httpd/conf/uos.conf
systemctl start httpd.service
- 下载
http:/virtual.storage.uosexam.com/exam/uos.html文件
(无此文件无法下 |
到/var/www/uos下并重命名为index.html
载)
下载命令如下:
wget -O /var/www/uos/index.html http:virtual.storage.uosexam.com/exam/uos.html
(问题(3)解决后(4) |
/var/www/uos/index.html的内容
即可完成访问)
4.安全web主机:
- 虚拟主机监听的端口为9999
vim /etc/httpd/conf/httpd.conf
生成自签名证书
openssl req -x509 -nodes -days 365 -newkey rsa:2048
-keyout /etc/pki/tls/private/uos.key -out
/etc/pki/tls/certs/uos.crt -subj
“/CN=Server1.uosexam.com”
创建SSL虚拟主机配置
vim /etc/httpd/conf.d/uos-ssl.conf
systemctl restart httpd.service
- 设置DocumentRoot为/var/www/uos
- 下载
http:/virtual.storage.uosexam.com/exam/uos.html 文
(无此文件无法 |
件到/var/www/uos下并重命名为index.html
下载)
(问题(3)解决后(4)即 |
- 访问http://Server1.uosexam.com:9999即可看到 var/www/uos/index.html的内容
(和 |
可完成访问)(5)为http://Server1.uosexam.com配置安全的web服务, 可以使用https:/Server1.uosexam.com去访问您的web
问题(4)没啥区别啊)
5.数据库MariaDB,在Server1上创建mariadb数据库,并实现
下列要求:(解决scott.sql文件问题和下载器途径问题)
- root密码设置为txuos
yum -y install mariadb-server
systemctl enable mariadb –now
mysqladmin -u root password ‘txuos’
- 下载
http://virtual.storage.uosexam.com/exam/scott.sql文
(无此文件无法下载) |
件
wget http://virtual.storage.uosexam.con/exam/scott.sql
- 导入 scott.sql文件(问题(2)下载后怎么操作?)
- 为deepin用户授权,只能访问scott库,密码为txuos
6.数据库内容查找,按照下列要求查询数据:
在scott库的emp表中查找deptno为30并且sal大于2000的人, 将查找出来的名字写入/var/lib/mysql/exam.txt中
(需下载问题(2)的内容,故无法操作)
命令如下:
7.你有两台服务器,Server1和Server2,它们运行着Ubuntu
或其他支持FTP服务的操作系统。Server1将作为FTP服务器, Server2将作为FTP客户端。你需要在Server1上创建一个FTP
服务,并配置特定的访问权限。
- 在Server1上安装并配置FTP服务器(如vsftpd),并创建
/srv/ftp/pub目录。 yum -y install vsftpd
mkdir -p /srv/ftp/pub
- 配置FTP服务器以允许匿名用户访问/srv/ftp/pub目录,
并赋予匿名用户在该目录中进行文件上传和下载的权限。
编辑/etc/vsftpd/vsftpd.conf,修改 anonymous_enable=YES anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES 同时把listen=NO改为YES 添加一行,设置匿名用户根目录anon_root=/srv/ftp listen_ipv6=YES这行需要注释掉,否则重启vsftpd的时候会报
错
chown ftp:ftp /srv/ftp/pub
chmod 755 /srv/ftp/ chmod 777 /srv/ftp/pub/
systemctl restart vsftpd
注1:为确保Server2正常使用ftp,我们在Server1上关闭防火墙
- 在Server2上配置FTP客户端,以确保可以使用匿名用户
身份连接到Server1上的FTP服务器,并在/srv/ftp/pub目录
中执行文件上传和下载操作。
yum -y install ftp ftp Server1
- 验证FTP服务是否按预期工作,即匿名用户是否能够在
/srv/ftp/pub目录中成功上传和下载文件。
上传测试
先进入pub目录,cd pub
下载测试
注:如果不能下载,到server1上给那个文件权限
8.你负责管理一台名为Server1的服务器,该服务器运行着支持FTP服务的操作系统(例如Uos)。你需要在Server1上部署
FTP服务器(如vsftpd),并创建四个用户账户。然而,你希望对这些用户的FTP访问权限进行精细控制,仅允许特定用户登录。
- 在Server1上安装并配置FTP服务器(如vsftpd)。
yum -y install vsftpd
- 创建以下四个FTP用户,每个用户的用户名和密码分别为:
user1:密码为’securepwd1′ user2:密码为’securepwd1′ user3:密码为’securepwd1′ user4:密码为’securepwd1′ useradd user1 && echo “user1:securepwd1” | chpasswd useradd user2 && echo “user2:securepwd1” | chpasswd useradd user3 && echo “user3:securepwd1” | chpasswd useradd user4 && echo “user4:securepwd1” | chpasswd
- 配置FTP服务器的user_list文件,采用“拒绝
(deny)”模式,即默认情况下拒绝所有用户登录。然后,仅
显式允许user1和user2用户登录,而user3和user4用户将被
拒绝访问
编辑/etc/vsftpd/vsftpd.conf文件,最下面添加两行
新建文件/etc/vsftpd/vsftpd.user_list,并把user1和user2添
加进去
注:这里可以直接把user1、user2添加到
/etc/vsftpd/user_list文件里,userlist_file应该
=/etc/vsftpd/user_list
重启vsftpd
关闭防火墙
(4)验证FTP服务器的配置是否生效,确保只有user1和
user2能够成功登录FTP服务器,而user3和user4无法登录。
验证user1、user2登录
验证user3、user4无法登录
9.在Server1上创建名为/root/check_status.sh的脚本。
编写脚本逻辑以完成以下功能:
- 判断传入的位置参数有且仅有一个。如果参数数量不符合要求,则脚本应输出错误信息并正常退出(退出码为0,表示成功执行了检查,但参数不符合要求)。
vim /root/check_status.sh
#!/bin/bash
if [ $# -ne 1 ]; then
echo “Error!” exit 0
fi
case “$1” in start) echo “booting” ;; stop) echo “shutdown” ;;
*) exit 12 ;;
esac
- 当执行脚本时,传入一个位置参数:如果参数为stop,
则输出shutdown。如果参数为start,则输出booting。
- 对于其它任意值,脚本应执行非正常退出,并设置退出码为12。
10.你需要在Server1上编写一个脚本,该脚本将根据传入的位 置参数使用不同的压缩工具对指定目录进行归档压缩。这个脚本需要能够识别并处理特定的参数,对于不符合要求的参数则输出错误信息。
(1)在Server1上创建名为/root/archive.sh的脚本。
编写脚本逻辑,使用case语句完成以下功能:
执行脚本时,传入一个位置参数,此参数应为zip、rar或者
7z三者之一。
如果参数为zip,则归档压缩/var/log目录至/backups目录中
,并命名为logs-2023.zip。
如果参数为rar,则归档压缩/var/log目录至/backups目录中,但注意,由于 rar可能不是系统默认安装的压缩工具,这里假设已安装,并命名为logs-2023.rar。如果参数为7z,则归档压缩/var/log目录至/backups目录中,并命名为logs-2023.7z。
如果参数为其它任意值,则输出Invalid parameter.Please use zip,rar,or 7z。 vim /root/archive.sh
赋权
chmod +x /root/archive.sh
验证
/root/archive.sh zip
/root/archive.sh 7z
看看脚本生成的内容
ls -l /backups/
注:题目里已经说明“由于 rar可能不是系统默认安装的压缩
工具,这里假设已安装,并命名为logs-2023.rar”,所以我
们脚本里写上行,也需要运行一下
11.Docker,在Server1上面搭建docker服务,满足下列要求:
(需解决httpd.tar包文件问题和下载途径问题)
- 下载
http:/virtual.storage.uosexam.com/exam/httpd.tar
(无此文件无法下载) |
的文件
yum -y install docker
systemctl start docker systemctl enable docker
wget http://virtual.storage.uosexam.com/exam/httpd.tar
- 导入httpd.tar到docker并将nginx设置为开机自动启
动
docker load -i httpd.tar docker run -d -p 8787:80 –name myhttpd –restart always httpd
- 在镜像中启动httpd服务并映射到Server1的8787端口, 访问内容为I’m UOS
docker exec myhttpd sh -c “echo ‘I’m UOS’ >
/usr/local/apache2/htdocs/index.html”
12.Ansible安装配置,在Server1上安装配置ansible,满足
下列要求:
- Server1在web组里面 yum -y install ansible cat > /etc/ansible/hosts <<EOF
[web]
Server1
[db]
Server2
EOF
- Server2在db组
13.编写一个名为/root/simple_install.yml的Ansible playbook。
配置playbook以满足以下要求:
(1)在web组中的服务器上安装软件包 httpd(或你系统上的
等效Web服务器软件,如apache2)。
vim /root/simple_install.yml
—
- hosts: web
tasks:
- name: Install Apache yum: name=httpd state=present
- name: Start and enable Apache service: name=httpd enabled=yes state=started
- hosts: db
tasks:
- name: Install MariaDB yum: name=mariadb-server state=present
- name: Start and enable MariaDB service: name=mariadb enabled=yes state=started
(2)在db组中的服务器上安装软件包mysql-server(或你系统上的等效数据库服务器软件,如mariadb-server)。
保证所有机器都是启动的、并实现开机自启动。
14.编写脚本(三),在Server1上,编写shell脚本:保存为/root/square.sh,要求找出1-20以内6的倍数,并打
印这些数的平方值 #注意最后打印的是什么值
vim /root/square.sh
#!/bin/bash
for i in {6..20..6}; do echo $((i*i)) done
sh /root/square.sh
15.FTP登录限制,在Server1上,安装vsFTP,并对用户登录限制,使用chroot_list方式:
- 创建xiyou、shuihu,两个FTP用户,密码为‘123456′ yum install vsftpd -y
sudo useradd -m xiyou sudo useradd -m shuihu echo “123456” | sudo passwd –stdin xiyou echo “123456” | sudo passwd –stdin shuihu
- 使用xiyou用户登录将被锁定目录,shuihu不被锁定
vim /etc/vsftpd/vsftpd.conf anonymous_enable=NO local_enable=YES write_enable=YES chroot_local_user=NO chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list allow_writeable_chroot=YES mkdir -p /etc/vsftpd echo “xiyou” | sudo tee /etc/vsftpd/chroot_list systemctl restart vsftpd systemctl enable vsftpd
验证
yum -y install lftp
xiyou用户被锁定
lftp -u xiyou,123456 localhost
ls .. # 应显示错误(如 “ls: Fatal error: Can’t
change directory”)
shuihu 用户不被锁定
lftp -u shuihu,123456 localhost
cd .. # 应能切换到上级目录 ls # 显示服务器根目录内容