RHCSA第一次作业

目录

1、创建以上目录和文件结构,并将/yasuo目录拷贝4份到/目录下

2、查看系统合法shell

3、查看系统发行版版本

4、查看系统内核版本

5、临时修改主机名

6、为/yasuo/ssh_config文件创建软链接/ssh_config.link到/mulu下

8、找到你的根目录下的所有块设备文件

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

10、复制/var/log/messages到/root目录下

11、创建目录/dir1,复制/etc/passwd文件到该目录

12、将/dir1/passwd重命名为passwd.back

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

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

15、在/根目录下创建一个haha目录

16、在/根目录下创建xixi文件

17、往xixi文件里面写'wo shi xixi ^=^'

19将xixi.link重命名为xixi.link2.0

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

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

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

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

(4) 开启VI的行号提示功能


1、创建以上目录和文件结构,并将/yasuo目录拷贝4份到/目录下

[root@localhost ~]# ls /yasuo               // 先检查是否有yasuo目录
ls: 无法访问 '/yasuo': 没有那个文件或目录
[root@localhost ~]# mkdir -p /yasuo/dir1     // 递归创建目录
[root@localhost ~]# tree /yasuo
/yasuo
└── dir1

1 directory, 0 files
[root@localhost ~]# cp /etc/hostname   /yasuo/dir1/        // 拷贝文件
[root@localhost ~]# cp /etc/hostname   /yasuo/dir1/hostname02
[root@localhost ~]# cp /etc/passwd   /yasuo/dir1/
[root@localhost ~]# cp /etc/ssh/ssh_config   /yasuo/dir1/
[root@localhost ~]# cp /etc/ssh/ssh_config   /yasuo/dir1/sshd
[root@localhost ~]# tree /yasuo/
/yasuo/
└── dir1
    ├── hostname
    ├── hostname02
    ├── passwd
    ├── ssh_config
    └── sshd

1 directory, 5 files
[root@localhost ~]# cp /yasuo/dir1/*   /yasuo/          
[root@localhost ~]# tree /yasuo/
/yasuo/
├── dir1
│     ├── hostname
│     ├── hostname02
│     ├── passwd
│     ├── ssh_config
│     └── sshd
├── hostname
├── hostname02
├── passwd
├── ssh_config
└── sshd

1 directory, 10 files
[root@localhost ~]# 
 

2、查看系统合法shell

[root@localhost ~]# echo $SHELL

/bin/bash

3、查看系统发行版版本

[root@localhost ~]# cat  /etc/redhat-release
Red Hat Enterprise Linux release 9.3 (Plow)

4、查看系统内核版本

[root@localhost ~]# uname  -r
5.14.0-362.8.1.el9_3.x86_64

5、临时修改主机名

[root@localhost ~]# hostname haha   // 临时修改

[root@localhost ~]# hostnamectl  hostname haha   // 永久修改

6、为/yasuo/ssh_config文件创建软链接/ssh_config.link到/mulu下

[root@hahaha ~]# ls -li  /mulu           // 首先查看mulu在不在
ls: 无法访问 '/mulu': 没有那个文件或目录
[root@hahaha ~]# mkdir  /mulu                 // 创建目录
[root@hahaha ~]# ln -s /yasuo/ssh_config  /mulu/ssh_config.link  // 创建软连接
[root@hahaha ~]# ls -li /yasuo/ssh_config  /mulu
36068157 -rw-r--r--. 1 root root 1921  8月  1 18:30 /yasuo/ssh_config

/mulu:
总用量 0
878306 lrwxrwxrwx. 1 root root 17  8月  2 12:25 ssh_config.link -> /yasuo/ssh_config

[root@hahaha ~]# mv /mulu /yasuo/mulu1 
[root@hahaha ~]# ls /yasuo/mulu1
root  ssh_config.link

8、找到你的根目录下的所有块设备文件

[root@hahaha ~]# find / -type b
/dev/dm-1
/dev/dm-0
/dev/sr0
/dev/nvme0n1p3
/dev/nvme0n1p2
/dev/nvme0n1p1
/dev/nvme0n1
/run/user/0/systemd/inaccessible/blk
/run/systemd/inaccessible/blk

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

[root@hahaha ~]# cp /etc/passwd /root/etc/
cp: 无法创建普通文件'/root/etc/': 没有那个文件或目录
[root@hahaha ~]# mkdir -p /root/etc
[root@hahaha ~]# ls /root/etc      # 新创建的/root/etc内没有任何文件
[root@hahaha ~]# 
[root@hahaha ~]# cp /etc/passwd  /root/etc/
[root@hahaha ~]# cp /etc/ssh/ssh_config  /root/etc/
[root@hahaha ~]# ls /root/etc
passwd  ssh_config

10、复制/var/log/messages到/root目录下

[root@hahaha ~]# ls /var/log/messages 
/var/log/messages
[root@hahaha ~]# cp /var/log/messages  /root
[root@hahaha ~]# ls /root
etc  messages

11、创建目录/dir1,复制/etc/passwd文件到该目录

[root@hahaha ~]# mkdir /dir1
[root@hahaha ~]# cp /etc/passwd  /dir1

12、将/dir1/passwd重命名为passwd.back

[root@hahaha ~]# mv /passwd /passwd.back
[root@hahaha ~]# ls /passwd
ls: 无法访问 '/passwd': 没有那个文件或目录
[root@hahaha ~]# ls /passwd.back 
/passwd.back

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

root@hahaha ~]#  ls -l /root  /aaaaa   1> /root/ok.file  2>/root/erro.file

root@hahaha ~]# ls -l /root /aaaaa
ls: 无法访问 '/aaaaa': 没有那个文件或目录
/root:
总用量 520
-rw-r--r--. 1 root root     55  8月  2 13:14 erro.file
drwxr-xr-x. 2 root root     38  8月  2 12:47 etc
-rw-------. 1 root root 522894  8月  2 12:54 messages
-rw-r--r--. 1 root root    236  8月  2 13:14 ok.file
[root@hahaha ~]# cat /root/ok.file
/root:
总用量 516
-rw-r--r--. 1 root root     55  8月  2 13:14 erro.file
drwxr-xr-x. 2 root root     38  8月  2 12:47 etc
-rw-------. 1 root root 522894  8月  2 12:54 messages
-rw-r--r--. 1 root root      0  8月  2 13:14 ok.file
[root@hahaha ~]# cat /root/erro.file
ls: 无法访问 '/aaaaa': 没有那个文件或目录

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

[root@hahaha ~]# ls -l /root /aaaaa &>/dev/null

15、在/根目录下创建一个haha目录

[root@hahaha ~]# mkdir /root/haha

[root@hahaha ~]# ll /root/haha
总用量 0

16、在/根目录下创建xixi文件

[root@hahaha ~]# touch /root/xixi
[root@hahaha ~]# ll /root/xixi
-rw-r--r--. 1 root root 0  8月  2 13:21 /root/xixi

17、往xixi文件里面写'wo shi xixi ^=^'

[root@hahaha ~]# echo  'wo shi xixi ^=^'  >  /xixi
[root@hahaha ~]# cat /xixi
wo shi xixi ^=^

[root@hahaha ~]# mkdir  /mulu
[root@hahaha ~]# ln -s  /root/xixi  /mulu/xixi.link
[root@hahaha ~]# ls -li  /mulu/xixi.link
18939533 lrwxrwxrwx. 1 root root 10  8月  2 13:28 /mulu/xixi.link -> /root/xixi

19将xixi.link重命名为xixi.link2.0

[root@hahaha ~]# mv  /mulu/xixi.link   /xixi.link2.0
[root@hahaha ~]# ls -li /xixi.link
ls: 无法访问 '/xixi.link': 没有那个文件或目录

[root@hahaha ~]# ls -li /xixi.link2.0
18939533 lrwxrwxrwx. 1 root root 10  8月  2 13:28 /xixi.link2.0 -> /root/xixi
 

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

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

[root@hahaha ~]# touch /tmp/newfile

[root@hahaha ~]# vim /tmp/newfile   // 进入到vi编辑器,按“a 、i、o”进入插入模式即可输入日期时间

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

按esc键进入命令模式,再按“ : ”进入末行模式,用命令"r(空格)/(文件路径)"读入文档内容

:r /boot/grub2/grub.cfg

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

‘ :’进入末行模式输入命令“g/搜索目标/d”

:g/#/d

(4) 开启VI的行号提示功能

进入末行模式输入命令“set nu”开启行号提示功能

:set nu

最后在末行模式输入:wq 保存退出

  • 22
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值