liunx exercise

云计算作业

Linux

DAY1
1、创建alan1用户,并使用root'用户切换用户至alan1用户。(两种方式切换【加-与不加-】,并总结其效果)
[root@localhost ~]# useradd alan1
[root@localhost ~]# su alan1
[alan1@localhost root]$ pwd
/root
[alan1@localhost root]$ exit
exit
[root@localhost ~]# su - alan1
上一次登录:三 8月  9 18:48:14 CST 2023pts/0 上
[alan1@localhost ~]$ pwd
/home/alan1
[alan1@localhost ~]$ #su 切换用户时,改变登录的用户名,不改变其家目录;su - 切换到普通用户时,不仅改变用户名,还改变了它所在的家目录
​

2、(预习看效果)查看本地时间,要求只显示分钟、小时、秒

[alan1@localhost ~]$ #2.显示当前时间时分秒
[root@localhost ~]# date +%X
10时22分59秒
​

3、查看/root下的文件信息,分别简单显示、人性化显示、详细显示以及显示隐藏文件。

[root@localhost ~]# #简单显示ls,人性化显示ll -h,详细显示ll ,隐藏文件ls -a
[root@localhost ~]# ls /root
1.txt  a  anaconda-ks.cfg  b  c  qianfeng
[root@localhost ~]# ll -h /root
总用量 4.0K
-rw-r--r--. 1 root root    0 8月   8 18:31 1.txt
-rw-r--r--. 1 root root    0 8月   8 13:48 a
-rw-------. 1 root root 1.3K 8月   8 11:38 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 8月   8 13:48 b
-rw-r--r--. 1 root root    0 8月   8 13:48 c
drwxr-xr-x. 3 root root   18 8月   8 18:31 qianfeng
[root@localhost ~]# ll /root
总用量 4
-rw-r--r--. 1 root root    0 8月   8 18:31 1.txt
-rw-r--r--. 1 root root    0 8月   8 13:48 a
-rw-------. 1 root root 1253 8月   8 11:38 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 8月   8 13:48 b
-rw-r--r--. 1 root root    0 8月   8 13:48 c
drwxr-xr-x. 3 root root   18 8月   8 18:31 qianfeng
[root@localhost ~]# ls -a /root
.   1.txt  anaconda-ks.cfg  .bash_history  .bash_profile  c       qianfeng
..  a      b                .bash_logout   .bashrc        .cshrc  .tcshrc
​
ls -d 显示当前文件夹的家目录 ll -d 查看当前文件的详细信息和家目录;
[root@localhost ~]# ls -a /home 
.  ..  alan1  tony1  tony2  tony3  tony4
[root@localhost ~]#  ls -ahl /home
总用量 0
drwxr-xr-x.  7 root  root   71 8月   9 18:48 .
dr-xr-xr-x. 17 root  root  224 8月   8 11:37 ..
drwx------.  2 alan1 alan1  83 8月   9 18:48 alan1
drwx------.  2 tony1 tony1  92 8月   9 16:55 tony1
drwx------.  2 tony2 tony2  83 8月   9 16:49 tony2
drwx------.  2  1002  1002  62 8月   9 11:10 tony3
drwx------.  2 tony4 tony4  62 8月   9 11:10 tony4
[root@localhost ~]# ls -ahld /home
drwxr-xr-x. 7 root root 71 8月   9 18:48 /home
​
​
​

4.Linux发行版有哪些?名字

中国:centOS
西方 ubantu
5.红帽认证是什么(搜百度)?
红帽认证[技师]/系统管理员(RHCSA),红帽认证[工程师](RHCE)和红帽认证[架构师](RHCA)
​
RHCA五门课程和考试
RHS333 Red Hat Enterprise Security: Network Services(安全:网络服务)
RH401 Red Hat Enterprise Deployment, Virtualization, and Systems Management(部署和系统管理员)
RH423 Red Hat Enterprise Directory Services and Authentication(目录服务和认证)
Clusterin英/ˈklʌstərɪŋ/集群
 Red Hat Enterprise Clustering and Storage Management(存储管理)
​
RH442 Red Hat Enterprise System Monitoring and Performance Tuning(系统监控和性能调整)

6.服务器的品牌有哪些?【中关村在线搜索】

超聚变,戴尔,浪潮,H3C,华为,惠普
1超聚变FusionServer 2288H价格面议
2戴尔易安信PowerEdge R740¥21397
3浪潮英信NF5280M6¥19399
4H3C UniServer R4900 G3(¥17099
5华为FusionServer RH2288H¥11987
6HP ProLiant DL380 Gen10(¥39800
7H3C UniServer R4900 G5价格面议
8超聚变FusionServer 2288H价格面议
9浪潮英信NF5280M5¥18300
10浪潮英信NF5270M6

7.找到CentOS官网进去查看一下。

8.安装一台centos虚拟机,要求该虚拟机安装成功后安装自动补全插件(bash-completion)。

yum -y install bash-completion
删除用户时,必须加-r,否则邮箱和家目录无法删除掉;当删除成功时显示提示信息加-v命令例如 rm -rfv
[root@localhost ~]# useradd heihei
[root@localhost ~]# ls /home
alan1  heihei  tony1  tony2  tony4
[root@localhost ~]# userdel heihei
[root@localhost ~]# ls /home
alan1  heihei  tony1  tony2  tony4
[root@localhost ~]# ls /var/spool/mail/
alan1  heihei  tony1  tony2  tony3  tony4
[root@localhost ~]# id heihei
id: heihei: no such user
[root@localhost ~]# rm -rf /home/heiehi
[root@localhost ~]# rm -rvf /var/spool/mail/heihei
已删除"/var/spool/mail/heihei"
​

DAY2
1.在/opt/test/dir1/test/目录下面创建20个test.txt文件

[root@localhost ~]# mkdir -p /opt/test/dir1/test ; touch /opt/test/dir1/test/test{1..20}.txt [root@localhost ~]# ls /opt/test/dir1/test/ test10.txt test14.txt test18.txt test2.txt test6.txt test11.txt test15.txt test19.txt test3.txt test7.txt test12.txt test16.txt test1.txt test4.txt test8.txt test13.txt test17.txt test20.txt test5.txt test9.txt

2.在/mnt/目录中创建dir2目录 [root@localhost ~]# mkdir -p /mnt/dir2 ; ls /mnt/ a A abc abcd.txt dir2 QF2307 tony.txt

3.将/opt/test/dir1/test/目录拷贝到/mnt/dir2目录中 [root@localhost ~]# rm -rf /mnt/* [root@localhost ~]# cp -rf /opt/test/dir1/test/ /mnt/dir2 ; ls /mnt/dir2 test13.txt test17.txt test20.txt test5.txt test9.txt test10.txt test14.txt test18.txt test2.txt test6.txt test11.txt test15.txt test19.txt test3.txt test7.txt test12.txt test16.txt test1.txt test4.txt test8.txt

4.将/mnt/dir2/目录中的test2.txt 改名为file300 mv /mnt/dir2/test2.txt /mnt/dir2/file300 ; ls /mnt/dir2 【后面的目录是更改后的名字】

file300 test12.txt test16.txt test1.txt test5.txt test9.txt test test13.txt test17.txt test20.txt test6.txt test10.txt test14.txt test18.txt test3.txt test7.txt test11.txt test15.txt test19.txt test4.txt test8.txt

5.将/mnt/dir2/目录中以txt结尾的文件删除。查看留下的文件 rm -rf /mnt/*txt ; ls /mnt/dir2/

[root@localhost ~]# rm -rf /mnt/dir2/*txt ; ls /mnt/dir2/ file300 test

1.若 file1 文件中有 1 行内容,file2 文件中有 3 行内容,执行完命令“cat < file1 > file2”后,file2

  • 1 行

2普通用户执行“ls -l /root > /tmp/test.txt”的结果是( )。

  • A显示/root 目录和/tmp/test.txt 文件信息

  • B显示/root 目录的详细列表,并重定向输出到/tmp/test.txt 文件

  • C将/root 目录的详细列表重定向到/tmp/test.txt,并报告错误

  • D报告错误信息

正确答案:D 普通用户没权限,无法查看;能够执行才能追加信息,前面不能执行,就会在页面上进行报错。

3。假设用户所使用的系统上有两块 IDE 硬盘,查询第二块硬盘的分区情况的命令为( )。
  • Afdisk -l /dev/hda1

  • Bfdisk -l /dev/had

  • Cfdisk -l /dev/hdb

  • Dfdisk -l /dev/hdb2

正确答案:C 软盘soft diak sd;硬盘hard disk hd 顺序依次为a...z

.4统计磁盘空间或文件系统使用情况的命令是( )。

  • Afdisk

  • Bdu

  • Cdd

  • Ddf

正确答案:A

/etc/fstab是用来存放文件系统的静态信息的文件。位于/etc/目录下,可以用命令less /etc/fstab 来查看,如果要修改的话,则用命令 vi /etc/fstab 来修改。

当系统启动的时候,系统会自动地从这个文件读取信息,并且会自动将此文件中指定的文件系统挂载到指定的目录。下面我来介绍如何在此文件下填写信息。

5.Linux 系统中文件系统的挂载配置文件是( )。

  • A/dev/sda

  • B/etc/profile

  • C/etc/passwd

  • D/etc/fstab

正确答案:D

.

.一、逻辑卷管理(LVM)概念 逻辑卷和逻辑卷管理有助于更加轻松地管理磁盘空间。 如果托管逻辑卷的文件系统需要更多空间可以将其卷组中的可用空间分配给逻辑卷,并且可以调整文件系统的大小。 如果磁盘开始出现错误,可以将替换磁盘注册为物理卷放入卷组中,并且逻辑卷的区块可迁移到新磁盘。

  1. LVM 定义 Logical Volume Manager 物理设备物理设备是用于保存逻辑卷中所存储数据的存储设备。 它们是块设备,可以是磁盘分区、整个磁盘、RAID 阵列或SAN 磁盘。 设备必须初始化为 LVM 物理卷,才能与 LVM 结合使用。整个设备将用作一个物理卷。

  2. 物理卷(PV) 物理卷是LVM 所使用的基础“物理”存储。在LVM 系统中使用设备之前,必须将设备初始化为物理卷。 LVM 工具会将物理卷划分为物理区块PE),它们是充当物理卷上最小存储块的小块数据。 组(VG) 卷组是存储池,由一个或多个物理卷组成。它在功能上与基本存储中的整个磁盘相当。一个 PV只能分配给一个 VG。VG 可以包含未使用的空间和任意数目的逻辑卷。 1

  3. 逻辑卷(LV) 逻辑卷根据券组中的空闲物理区块创建,提供应用、用户和操作系统所使用的“存储”设备。LV是逻辑区块(LE)的集合,LE 映射到物理区块 (PV的最小存储块)。 默认情况下,每个LE 将映射到一个 PE。设置特定 LV 选项将会更改此映射,例如,镜像会导致每个LE 映射到两个PE。

    物理分区或磁盘是 LVM 的第一构建块。这些可以是分区、完整磁盘、 RAID 集或 SAN 磁盘。
    物理卷(PV)是 LVM 所使用的基础 “物理 ”存储。这通常是块设备,例如分区或完整磁盘。设备必须初始化为LVM 物理卷 ,才能与 LVM 结合使用。
    物理卷组(VG)是存储池, 由一个或多个物理卷组成。
    物理区块(PE)是物理卷中存储的小型数据区块,用作 LVM 存储的后端。
    逻辑区块映射到物理区块 ,构成 LVM 存储的前端。默认情况下,每个逻辑区块映射到一个物理区块。启用某些选项将更改此映射。例如 , 镜像会导致每个逻辑区块映射到两个物理区块,逻辑卷是逻辑区块组。逻辑卷可以像硬盘驱动器分区一样使用。

    我们的物理分区就相当于橙子,有几个分区就有几个橙子,现在我们把两个橙子榨成汁,放入各自的杯子中,即物理卷,我们把两杯橙汁倒入一个大容器中,即物理卷组,我们每次拿一个小杯子喝,即逻辑卷,喝完了再从大杯子(物理卷组)里倒,大杯子(物理卷组)橙汁不够,我们再用橙子(物理分区)继续榨汁倒入大杯子就行

    二、创建逻辑卷

  4. pvcreate命令将分区标记为物理卷,创建物理卷pvcreate /dev/vdb1 /dev/vdb2

  5. vgcreate命令将一个或多个物理卷结合为一个卷组,创建卷组vgcreate servera_01_vg /dev/vdb1 /dev/vdb2

  6. lvcreate命令根据卷组中的可用物理区块,创建逻辑卷

    lvcreate -n 设置LV名称 lvcreate -L 设置LV大小(以字节为单位) lvcreate -l 设置LV大小(以区块数为单位)以及托管此逻辑卷的卷组的名称 lvcreate -n servera_01_lv -L 400M servera_01_vg

  1. mkfs 在新逻辑卷上创建XFS 文件系统。mkfs -t xfs /dev/servera_01_vg/servera_01_lv

  1. df -h命令显示磁盘文件的大小df -h /data 1

  2. 三、查看 LVM 状态信息

  3. pvdisplay 显示有关物理卷的信息pvdisplay /dev/vdb

  4. vgdisplay显示卷组的信息vgdisplay servera_01_vg

  1. lvdisplay 显示逻辑组的信息lvdisplay /dev/servera_01_vg/servera_01_lv

四、删除逻辑卷

  1. lvremoveDEVICENAME删除逻辑卷。Ivremove /dev/vg01/1v01

  2. vgremove 删除不再需要的卷组。vgremove vg01 VG的物理卷会被释放,并可用于分配给系统中的现有VG或新VG。

  3. pvremove删除物理卷pvremove /dev/vdb2 /dev/vdb1 用空格分隔的 PV设备列表同时删除多个PV。此命令将从分区(或磁盘) 中删除 PV 元数据。分区现已空闲,可重新分配或重新格式化。

( )命令可以将物理硬盘初始化为物理卷。

  • Avgcreate

  • Blvcreate

  • Cpvcreate

  • Dvgscan

正确答案:C

( )命令用来重定向管道的输出到标准输出和指定文件。
  • A tee B cat C less D wee

    正确答案:A

    ( )命令可在环境

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

m0_45442261

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值