还剩5页未读,继续阅读
文本内容:
文件系统管理linux(判断文件类型的命令)file(练习在虚拟机上添加一块硬盘后重新启动机器,在命令行下查看》浮现如下信息证明硬[root@localhost~]#dmesg|grep sdb盘加载成功!()sd2:0:1:0:[sdb]***-*****512-byte logicalblocks:
10.7GB/
10.0GiBsd2:0:1:0:[sdb]Write Protectis offsd2:0:1:0:[sdb]Mode Sense:61000000sd2:0:1:0:[sdb]Cache dataunavailablesd2:0:1:0:[sdb]Assuming drivecache:write throughsd2:0:1:0:[sdb]Cache dataunavailablesd2:0:1:0:[sdb]Assuming drivecache:write throughsdb:unknownpartition tablesd2:0:1:0:[sdb]Cache dataunavailablesd2:0:1:0:[sdb]Assuming drivecache:write throughsd2:0:1:0:[sdb]Attached SCSIdisk划分分区常用的几个选项匡助m:显示分区表p:添加新分区n改变分区文件系统类型t:删除分区d:保存分区并退出w:不保存退出q文件解释/etc/fstab/dev/cdrom/mnt iso9660defaults00物理分区名/卷标挂载点文件类型缺省设置是否检测检测0/1顺序0/1/2Acl:[root@peng〜]#Is-Id/redhat/drwxr-xr-x.2root root4096Sep2403:18/redhat/[root@peng~]#su-useri[user1@peng~]$cd/redhat/[user1@peng redhat]$touch file》止匕时权限不touch:cannot touch file:Permission denied够!对文件增[root@peng〜]#setfacl-m u:user1:rwx/redhat/——/redhat加权限acl[root@peng~]#Is-Id/redhat/drwxrwxr-x+2root root4096Sep2403:18/redhat/[root@peng su-useri[user1@peng〜]$cd/redhat/》再次切换到用[user1@peng redhat]$touch file.txt useri户下可以创建文件![user1@peng redhat]$IItotal0-rw-rw-r-.1useri useri0Sep2403:21file.txt》切换到其他用户则操作不[root@peng-]#su-user2被允许![user2@peng〜]$cd/redhat/[user2@peng redhat]$touchfile
2、touch:cannot touchfile2:Permission denied[root@peng data]#mountsda13/data/[root@peng data]#df-hFilesystem SizeUsed AvailUse%Mounted on/dev/sda
29.9G
6.0G
3.5G64%/tmpfs497M72K497M1%/dev/shm/dev/sda1194M29M156M16%/boot/dev/sda31008M134M824M14%/home/dev/srO
3.5G
3.5G0100%/mnt/dev/sda13198M
5.8M182M4%/data[root@peng data]#setfacl-m u:user1:rwx/redhat/[root@pengdata]#setfacl-m u:user1:rwx/data/setfacl:/data/:Operation notsupported》查看默认时不支持[root@peng data]#tune2fs-I/dev/sda13功能!aclDefault mountoptions:none要想让目录有功能,需要在配置文件下加入如下一/data acl/etc/fstab行,总结默认情况下,在系统创建的时候分的区,默认是具有权限的;acl而在系统创建之后创建的分区,则不具有功能!acl测试权限的优先级acl[root@peng~]#Is-Id/data/dr-xr-xr-x.3user2user21024Sep2403:27/data/[root@peng~]#setfacl-m u:user2:rwx/data/[root@peng~]#su-user2[user2@peng~]$cd/data/[user2@peng data]$touch user
2、touch:cannot touch user2:Permission denied[root@peng chownuseri/data/[root@peng~]#Is-Id/data/dr-xrwxr-x+3useri user21024Sep2403:27/data/[root@peng~]#getfacl/data/getfacl:Removing leading7from absolutepath names#file:data/#owner:useri#group:user2user::r-x user:user2:rwxgroup::r-xmask::rwxother::r-x》切换到用户下查看可以[root@peng〜]#su-user2user2创建文件[user2@peng~]$cd/data/[user2@peng data]$touchuser
2.txt[user2@peng data]$IItotal13drwx.2root root*****Sep2403:27lost+found-rw-rw-r-.1user2user20Sep2404:09user
2.txt文件拥有人本身的权限比文件拥有人权限高,文件拥有组权限比文acl件拥有组权限高acl总结若是文件拥有人,则应用文件拥有人的权限;若对文件有权acl限,则应用权限;否则再比较若是文件的拥有组,则应用文件拥有组的acl权限;若对文件组有权限,则应用权限;如果都没有则应用其他人acl acl的权限!用户名目录(只对目录的权限设置)setfacl-m d:u:rwx acl)文件的实现步骤1:[root@localhost~]#mkdir/var/swap》创建文件[root@localhost~]#chmod700/var/swap并赋予权限700步骤2[root@localhost~]#dd if=/dev/zero of=/var/swap/swap.file》创建文件大小为的文件bs=1024kcount=64——64M64+0records in64+0records out***-*****bytes67MB copied,
0.*****s,
89.2MB/s》[root@localhost~]#du-h/var/swap/swap.file查看已经创建的文件64M/var/swap/swap.file步骤3[root@localhost free-mtotal usedfree sharedbuffers cachedMem:992367625030172-/+buffers/cache:164827》查看止匕时的大小Swap:102301023swap为1023M步骤4》[root@localhost~]#swapon/var/swap/swap.file拉伸的大小swap步骤5[root@localhost~]#free-mtotal usedfree sharedbuffers cachedMem:992366625030172-/+buffers/cache:164828》再次查看此时的大Swap:108701087swap小已经为,是之前的与之和的结果!1087M1023M64M步骤可以把如下内容写在文件中!6/etc/fstab/var/swap/swap.file swapswap defaults00空间大小一软限制硬限制blocks Kbsoft hard。
个人认证
优秀文档
获得点赞 0