linux文件系统管理

上传人:第*** 文档编号:32688651 上传时间:2018-02-12 格式:DOCX 页数:9 大小:1.06MB
返回 下载 相关 举报
linux文件系统管理_第1页
第1页 / 共9页
linux文件系统管理_第2页
第2页 / 共9页
linux文件系统管理_第3页
第3页 / 共9页
linux文件系统管理_第4页
第4页 / 共9页
linux文件系统管理_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《linux文件系统管理》由会员分享,可在线阅读,更多相关《linux文件系统管理(9页珍藏版)》请在金锄头文库上搜索。

1、(判断文件类型的命令:file)(:在虚拟机上添加一块硬盘后重新启动机器,在命令行下查看:rootlocalhost # dmesg |grep sdb-出现如下信息证明硬盘加载成功!sd 2:0:1:0: sdb 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)sd 2:0:1:0: sdb Write Protect is offsd 2:0:1:0: sdb Mode Sense: 61 00 00 00sd 2:0:1:0: sdb Cache data unavailablesd 2:0:1:0: sdb Assuming dr

2、ive cache: write throughsd 2:0:1:0: sdb Cache data unavailablesd 2:0:1:0: sdb Assuming drive cache: write throughsdb: unknown partition tablesd 2:0:1:0: sdb Cache data unavailablesd 2:0:1:0: sdb Assuming drive cache: write throughsd 2:0:1:0: sdb Attached SCSI disk划分分区常用的几个选项:m:帮助p: 显示分区表n:添加新分区t: 改变

3、分区文件系统类型d: 删除分区w: 保存分区并退出q: 不保存退出)(/etc/fstab 文件解释:/dev/cdrom /mnt iso9660 defaults 0 0物理分区名/卷标 挂载点 文件类型 缺省设置 是否检测(0/1) 检测顺序(0/1/2)Acl:rootpeng # ls -ld /redhat/drwxr-xr-x. 2 root root 4096 Sep 24 03:18 /redhat/rootpeng # su - user1user1peng $ cd /redhat/user1peng redhat$ touch filetouch: cannot tou

4、ch file: Permission denied-此时权限不够!rootpeng # setfacl -m u:user1:rwx /redhat/-对/redhat 文件增加 acl 权限rootpeng # ls -ld /redhat/drwxrwxr-x+ 2 root root 4096 Sep 24 03:18 /redhat/rootpeng # su - user1user1peng $ cd /redhat/user1peng redhat$ touch file.txt-再次切换到 user1 用户下可以创建文件!user1peng redhat$ lltotal 0-

5、rw-rw-r-. 1 user1 user1 0 Sep 24 03:21 file.txtrootpeng # su - user2-切换到其他用户则操作不被允许!user2peng $ cd /redhat/user2peng redhat$ touch file2touch: cannot touch file2: Permission deniedrootpeng data# mount /dev/sda13 /data/rootpeng data# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda2 9.9G 6.0G

6、3.5G 64% /tmpfs 497M 72K 497M 1% /dev/shm/dev/sda1 194M 29M 156M 16% /boot/dev/sda3 1008M 134M 824M 14% /home/dev/sr0 3.5G 3.5G 0 100% /mnt/dev/sda13 198M 5.8M 182M 4% /datarootpeng data# setfacl -m u:user1:rwx /redhat/rootpeng data# setfacl -m u:user1:rwx /data/setfacl: /data/: Operation not suppor

7、tedrootpeng data# tune2fs -l /dev/sda13-查看默认时不支持 acl 功能!Default mount options: (none)要想让/data 目录有 acl 功能,需要在 /etc/fstab 配置文件下加入如下一行,总结:默认情况下,在系统创建的时候分的区,默认是具有 acl 权限的;而在系统创建之后创建的分区,则不具有 acl 功能!测试 acl 权限的优先级:rootpeng # ls -ld /data/ dr-xr-xr-x. 3 user2 user2 1024 Sep 24 03:27 /data/rootpeng # setfacl

8、 -m u:user2:rwx /data/rootpeng # su - user2user2peng $ cd /data/user2peng data$ touch user2touch: cannot touch user2: Permission deniedrootpeng # chown user1 /data/rootpeng # ls -ld /data/dr-xrwxr-x+ 3 user1 user2 1024 Sep 24 03:27 /data/rootpeng # getfacl /data/getfacl: Removing leading / from abso

9、lute path names# file: data/# owner: user1# group: user2user:r-xuser:user2:rwxgroup:r-xmask:rwxother:r-xrootpeng # su - user2-切换到 user2 用户下查看可以创建文件user2peng $ cd /data/user2peng data$ touch user2.txtuser2peng data$ lltotal 13drwx-. 2 root root 12288 Sep 24 03:27 lost+found-rw-rw-r-. 1 user2 user2 0

10、Sep 24 04:09 user2.txt文件拥有人本身的权限比文件拥有人 acl 权限高,文件拥有组权限比文件拥有组 acl 权限高。总结:若是文件拥有人,则应用文件拥有人的权限;若对文件有 acl 权限,则应用 acl 权限;否则再比较若是文件的拥有组,则应用文件拥有组的权限;若对文件组有 acl 权限,则应用 acl 权限;如果都没有则应用其他人的权限!setfacl -m d:u:用户名:rwx 目录 ( 只对目录的权限设置 acl )SWAPFILE 文件的实现步骤 1: rootlocalhost # mkdir /var/swaprootlocalhost # chmod 70

11、0 /var/swap-创建文件并赋予权限 700步骤 2:rootlocalhost # dd if=/dev/zero of=/var/swap/swap.file bs=1024k count=64-创建文件大小为 64M 的文件64+0 records in64+0 records out67108864 bytes (67 MB) copied, 0.752198 s, 89.2 MB/srootlocalhost # du -h /var/swap/swap.file -查看已经创建的文件64M /var/swap/swap.file步骤 3:rootlocalhost # fre

12、e -mtotal used free shared buffers cachedMem: 992 367 625 0 30 172-/+ buffers/cache: 164 827Swap: 1023 0 1023-查看此时 swap 的大小为1023M。步骤 4:rootlocalhost # swapon /var/swap/swap.file-拉伸 swap 的大小步骤 5:rootlocalhost # free -mtotal used free shared buffers cachedMem: 992 366 625 0 30 172-/+ buffers/cache: 164 828Swap: 1087 0 1087-再次查看此时的 swap 大小已经为 1087M,是之前的 1023M 与 64M 之和的结果!步骤 6:可以把如下内容写在/etc/fstab 文件中!/var/swap/swap.file swap swap defaults 0 0(blocks 空间大小 Kb soft:软限制 hard:硬限制Inodes 文件多少)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 职业教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号