-
添加一块10G大小的磁盘,将该磁盘分为两个主分区,大小为1G、2G。将剩余的空间全部划分为扩展分区。划分一个逻辑分区,大小为3G。(主分区文件系统类型为ext4,逻辑分区文件系统类型为xfs)
关机状态下添加10G的硬盘
[root@localhost ~]# fdisk /dev/sdb
创建主分区
创建扩展分区,划出逻辑分区
保存并退出
[root@localhost ~]# partprobe //将分区信息加载到内核
[root@localhost ~]# mkfs.ext4 /dev/sdb1 //更改主分区格式
[root@localhost ~]# mkfs.ext4 /dev/sdb2
[root@localhost ~]# mkfs.xfs /dev/sdb5 //更改逻辑分区格式[root@localhost ~]# blkid //查看磁盘格式
2. 将三个分区分别挂载到/donggua、/xigua、/nangua。
[root@localhost ~]# mkdir /donggua /xigua /nangua
[root@localhost ~]# mount /dev/sdb1 /donggua
[root@localhost ~]# mount /dev/sdb2 /xigua
[root@localhost ~]# mount /dev/sdb5 /nangua
[root@localhost ~]# mount | grep sdb //查看挂载的磁盘
3. 在第一个主分区中创建一个文件为file1,内容为this is partition1。在第二个分区中创建一个文件为file2,内容为this is partition2。在第三个分区中创建一个文件为file3,内容为"this is partition3"。
[root@localhost ~]# echo "this is partition1" > /donggua/file1
[root@localhost ~]# echo "this is partition2" > /xigua/file2
[root@localhost ~]# echo "this is partition3" > /nangua/file3
[root@localhost ~]# cat /donggua/file1 /xigua/file2 /nangua/file3
4. 实现一个功能,当使用任何用户创建目录的时候,它的所属者为root。
[root@localhost ~]# chmod u+s /usr/bin/mkdir
5. 创建一个目录为/exercise,在该目录下创建一个目录为red,实现一个功能:任何用户在red目录下创建文件的时候的所属组为redhat。
[root@localhost ~]# mkdir -pv /exercise/red
[root@localhost ~]# chgrp redhat /exercise/red
[root@localhost ~]# chmod g+s /exercise/red
[root@localhost ~]# chmod 777 /exercise/red
6. 在exercise目录下创建一个目录为nochange,任何普通用户都只能删除自己在该目录下创建的文件,无法删除其他用户创建的文件。
[root@localhost ~]# mkdir /exercise/nochange
[root@localhost ~]# chmod o+t /exercise/nochange
[root@localhost ~]# chmod 777 /exercise/nochange