当前位置: 首页 > news >正文

RHCSA复习题

~七章

#08查看系统合法shell

[root@localhost ~]# cat /etc/shells

#09查看系统发行版版本

[root@localhost ~]# cat /etc/redhat-release

Red Hat Enterprise Linux release 9.3 (Plow)

#10查看系统内核版本

[root@localhost ~]# uname -a

Linux localhost.localdomain 5.14.0-362.8.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Tue OcDT 2023 x86_64 x86_64 x86_64 GNU/Linux

#11临时修改主机名

[root@localhost ~]# hostname

tangxuan

[root@localhost ~]# hostname yangxuan

[root@localhost ~]# hostname

yangxuan

#12查看系统指令的查找路径

[root@yangxuan ~]# echo $PATH

/root/.local/bin:/root/bin:/home/yx/.local/bin:/home/yx/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

#13查看passwd指令的执行路径

[root@yangxuan ~]# which passwd

/usr/bin/passwd

#14为/yasuo/ssh_config文件在/mulu目录下创建软链接,软链接名称为ssh_config.link

[root@yangxuan ~]# mkdir /mulu

[root@yangxuan ~]# ln  -s /yasuo/ssh_config /mulu/ssh_config.link

[root@yangxuan ~]# ls /mulu

ssh_config.link

#15创建目录/mulu ,重命名并移动/ssh_config.link

[root@yangxuan ~]# mkdir /mulu

#16找到你的根目录下的所有块设备文件

[root@yangxuan ~]# find / -type b

#17将/etc/passwd和/etc/ssh/sshd_config文件复制到/root/etc/目录下

[root@yangxuan ~]# mkdir -p /root/etc/

[root@yangxuan ~]# cp /etc/passwd /etc/ssh/sshd_config /root/etc/

[root@yangxuan ~]# ls /root/etc/

passwd  sshd_config

#18复制/var/log/messages到/root目录下

[root@yangxuan ~]# cp /var/log/messages /root/

[root@yangxuan ~]# ls /root/messages

/root/messages

#19打包/root/messages和/root/etc/为/root/me.tar.bz2

[root@yangxuan ~]# tar -cvf /root/me.tar.bz2 /root/messages /root/etc/

#20解压/root/me.tar.bz2

[root@yangxuan ~]# tar -xvf /root/me.tar.bz2

#22找到/etc/passwd中有root信息的行内容

[root@yangxuan ~]# grep 'root' /etc/passwd

#30创建目录/dir1,复制/etc/passwd文件到该目录

[root@yangxuan ~]# mkdir /dir1

[root@yangxuan ~]# cp /etc/passwd /dir1/

[root@yangxuan ~]# ls /dir1

passwd

#31将/dir1/passwd重命名为passwd.back

[root@yangxuan ~]# mv /dir1/passwd   /dir1/passwd.back

#32列出目录/root和/aaaaa,将标准输出重定向到ok.file,标准错误输出重定向到erro.file

[root@localhost ~]# ls /root /aaaaa > ok.file 2> erro.file

#33列出目录/root和/aaaaa,将标准输出和标准错误输出都丢掉

[root@localhost ~]# ls /root /aaaaa > /dev/null 2>&1

#34在/根目录下创建一个haha目录

[root@yangxuan ~]# mkdir /haha

#35在/根目录下创建xixi文件

[root@yangxuan ~]# touch /xixi

#36往xixi文件里面写'wo shi xixi ^=^'

[root@yangxuan ~]# vim xixi

echo 'wo shi xixi'  >  /xixi

单引号:一模一样写入

双引号:先执行后输出

#37为文件xixi在/目录下创建软链接xixi.link

[root@yangxuan ~]# ln  -s  /xixi /xixi.link

#38将xixi.link重命名为xixi.link2.0

[root@yangxuan ~]# mv  /xixi.link  /xixi.link2.0

#39说说Linux系统中里/etc /dev 目录

/etc目录存储了系统的配置文件,定义了系统的基本设置和行为;

/dev目录则包含了设备文件,使得用户可以通过文件系统的接口与硬件设备进行交互

#40过滤/etc/ssh/sshd.conf不显示注释行和空行

[root@yangxuan ~]# grep -v ^# /etc/ssh/sshd_config | grep -v ^$

#41在/opt目录下创建一个临时目录tmp;

[root@yangxuan ~]# mkdir /opt/tmp

#42在临时目录/opt/tmp下创建一个文件,文件名为a.txt;

使用vim编辑器完成以下步骤:

[root@yangxuan ~]# touch /opt/tmp/a.txt

#44应用vim命令在/tmp文件夹下创建文件,文件名newfile。在newfile首行输入日期时间

[root@yangxuan ~]# vim /tmp/newfile

#45将/boot/grub2/grub.cfg文档的内容读入到newfile文档中(在日期的下一行即第2行)

[root@localhost ~]# vim /tmp/newfile

在vim的命令模式下,输入::r /boot/grub2/grub.cfg

#46 查找newfile文档中包含#号字符的行,将整行删除

[root@localhost ~]# vim /tmp/newfile

在vim的命令模式下,输入: :g/^#/d

#47 开启VI的行号提示功能

命令行输入 vi ~/.vimrc,在文件中添加set number保存退出。

#48在当前目录及子目录中,查找文件名字以大写字母开头的txt文件

[root@yangxuan ~]# find . -name '[A-Z]*.txt'

.当前目录开始找   -type f指定类型为文件

#49在/etc及其子目录中,查找文件内容以host开头的文件

[root@yangxuan ~]# grep -r '^host' /etc/

-r 表示递归搜索目录

#50在$HOME目录及其子目录中,查找所有文件

[root@yangxuan ~]# find $HOME -type f

#51查找文件/etc/passwd中包含字符串 /bin/bash 的所有行。将所有这些行的副本按原始顺序放在文

件/root/files 中

[root@yangxuan ~]# grep /bin/bash /etc/passwd

[root@yangxuan ~]# grep /bin/bash /etc/passwd > /root/files

#52将整个 /etc 目录下的文件全部打包并用 gzip 压缩成/back/etcback.tar.gz

tar -cvf /back/etcback.tar.gz  /etc

#53使当前用户永久生效的命令别名:写一个命令命为hello,实现的功能为每输入一次hello命令,就有hello,

everyone写入文件/file.txt中。

[root@localhost ~]# alias hello='echo "hello,everyone" >> /file.txt'

第八章 用户管理

#2、创建myuser用户属于mygroup组群,接着以myuser身份登录,创建ex和hv两个文件于/home/myuser目录,并使hv文件的所属组是mygroup。请依次写出相应的执行命令

[root@localhost ~]# groupadd mygroup

[root@localhost ~]# useradd -g mygroup myuser

[root@localhost ~]# passwd myuser

[yangxuan@localhost ~]$ su - myuser

[myuser@localhost ~]$ touch /home/myuser/ex

[myuser@localhost ~]$ touch /home/myuser/hv

[myuser@localhost ~]$ chgrp mygroup /home/myuser/hv

第九章 权限管理

#2、新建/sc目录,所属组为group组,root用户和group组用户可在该目录下创建文件,其他人无任何权限

[root@localhost ~]# mkdir /sc

[root@localhost ~]# groupadd group

[root@localhost ~]# chown :group /sc

[root@localhost ~]# chmod 770 /sc

[root@localhost ~]# ll -d /sc

drwxrwx---. 2 root group 6 10月 11 09:15 /sc

第十章 磁盘管理

#1、添加一块10G大小的硬盘,将该磁盘分为两个主分区,大小为1G、2G。将剩余的空间全部划分为扩展分区。划分 一个逻辑分区,大小为3G。(主分区的文件系统类型为ext4,逻辑分区文件系统类型为xfs)

[root@localhost ~]# lsblk

[root@localhost ~]# fdisk /dev/sda

[root@localhost ~]# mkfs.ext4 /dev/sda1

[root@localhost ~]# mkfs.ext4 /dev/sda2

[root@localhost ~]# mkfs.xfs /dev/sda5

#2、将三个分区分别挂载到/dir1 、/dir2、/dir3

[root@localhost ~]# mount /dev/sda1 /dir1

[root@localhost ~]# mount /dev/sda1 /dir2

[root@localhost ~]# mount /dev/sda5 /dir3

#3、在第一个主分区中创建一个文件file1,内容为this is partition1。在第二个分区中创建一个文件为 file2,内容为this is partition2。在第三个分区中创建一个文件为file3,内容为this is partition3。

echo "this is partition1"  > /dir1/file1

echo "this is partition2"  > /dir2/file2

echo "this is partition3"  > /dir3/file3

第十一章 网络管理

#为网卡添加一个会话static,在此会话配置ip地址为x.x.x.123

[root@localhost ~]# nmcli c add type ethernet con-name static ifname ipv4.addresses '192.168.110.123/24' ipv4.gateway 192.168.1.254 ipv4.dns '4.4.4.4' ipv4.method manual autoconnect yes

连接 "static" (b0ca27f9-cad3-4d56-a935-6bbeacb147fb) 已成功添加。

#测试网络连通性,是否能ping通百度,并把百度首页文件下载下来

ping www.baidu.com

#设置系统开机时,该网卡通过DHCP协议自动获取ip地址

dhclient ens160

sysytemctl restart NetworkManager

第十二章 软件管理

#挂载本地光盘,配置yum本地源为rhel9.repo

mount /dev/sr0/mnt

ls /mnt

cd /etc/yum.repos.d

mkdir bak

mv  *.repo  ./bak/

vim local.repo

写下以下内容:

[RHEL9-BaseOS]
name=RHEL9-BaseOS
baseurl=file:///mnt/BaseOS
gpgcheck=0
[RHEL9-Appstream]
name=RHEL9-Appstream
baseurl=file:///mnt/AppStream
gpgcheck=0
yum clean all
yum makecache

#通过yum安装httpd

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# mkdir bak

[root@localhost yum.repos.d]# mv *.repo bak/

[root@localhost yum.repos.d]# vim local.repo

[root@localhost yum.repos.d]# yum clean all

[root@localhost yum.repos.d]# yum makecache

[root@localhost yum.repos.d]# yum install httpd

#卸载httpd

[root@localhost ~]# systemctl stop httpd.service

[root@localhost ~]# yum remove httpd

[root@localhost ~]# yum list installed | grep httpd


http://www.mrgr.cn/news/50555.html

相关文章:

  • WebServer构建响应 发送响应
  • 如何解决数字化转型的老大难,突破部门流程墙
  • 歌曲怎么去掉原唱只留伴奏?创作无界,轻松获取伴奏音轨
  • 第1章:Flux学习前言(必读)
  • 游游的you(贪心+思路+代码)
  • AWS账号与邮箱的关系解析
  • 鲸鸿动能广告助力App流量高效变现,促进商业增长
  • goDoH:一款使用了DNS-over-HTTPS作为传输端口的C2框架
  • 《Linux运维》之解决“Failed to start LSB: Bring up/down networking.“问题的方法
  • 克隆容量不同的硬盘
  • 2024年中小企业数字化转型路径方法落地步骤
  • Linux下ClamAV源代码安装与使用说明
  • Maven高级
  • 百果园利润暴跌收入下滑:加盟店减少88家,销售费用却大幅增长
  • 新款任天堂switch游戏机方案,支持4K60HZ投屏方案,显示器,手柄方案
  • 【杂谈】ArcGIS操作小技巧,过来看看
  • 文字转语音怎么弄?一键点亮自媒体必备的配音技能
  • springboot 整合spring ai实现 基于知识库的客服问答
  • 初始化列表、静态成员、友元
  • comfyui实操:一个工作流让照片动起来!