马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!Centos默许装置无指定分区的时分,逻辑卷没有自力的/tmp简单形成宁静隐患,/dev/shm也是隐患之一
- #dd一个1G的文件,文件/.tmpfs
- ddif=/dev/zeroof=/.tmpfsbs=1Mcount=1000
- #创立文件体系
- mke2fs-j/.tmpfs
- ####################
- mke2fs1.41.12(17-May-2010)
- /.tmpfsisnotablockspecialdevice.
- Proceedanyway?(y,n)y
- Filesystemlabel=
- OStype:Linux
- Blocksize=4096(log=2)
- Fragmentsize=4096(log=2)
- Stride=0blocks,Stripewidth=0blocks
- 64000inodes,256000blocks
- 12800blocks(5.00%)reservedforthesuperuser
- Firstdatablock=0
- Maximumfilesystemblocks=264241152
- 8blockgroups
- 32768blockspergroup,32768fragmentspergroup
- 8000inodespergroup
- Superblockbackupsstoredonblocks:
- 32768,98304,163840,229376
- Writinginodetables:done
- Creatingjournal(4096blocks):done
- Writingsuperblocksandfilesystemaccountinginformation:done
- Thisfilesystemwillbeautomaticallycheckedevery32mountsor
- 180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
- ####################
- #复制文件
- cp-av/tmp/tmp.old
- #挂载之前dd的文件
- mount-oloop,noexec,nosuid,rw/.tmpfs/tmp
- #赋默许/tmp的权限
- chmod1777/tmp
- #把刚复制进来的文件移返来
- mv-f/tmp.old/*/tmp/
- #删除文件夹
- rm-rf/tmp.old
- #修正/etc/fstab使它重启后主动挂载
- /.tmpfs/tmpext3loop,nosuid,noexec,rw00
- #软链接/var/tmp到/tmp
- mv/var/tmp/var/tmp_bak
- ln-s/tmp/var/tmp
- cp-Rf/var/tmp_bak/*/var/tmp
- rm-rf/var/tmp_bak/
- #测试
- #分离到/tmp与/dev/shm目次里,创立可实行文件,并授与777权限
- [root@localhost/tmp]
- #ls-lA/tmp/|grepx.sh
- -rwxrwxrwx1rootroot22Jul2515:08x.sh
- [root@localhost/tmp]
- #cat/tmp/x.sh
- #!/bin/bash
- echotest
- [root@localhost/tmp]
- #/tmp/x.sh
- -bash:/tmp/x.sh:Permissiondenied
- [root@localhost/dev/shm]
- #ls-lA|grepx.sh
- -rwxrwxrwx1rootroot22Jul2515:08x.sh
- [root@localhost/dev/shm]
- #catx.sh
- #!/bin/bash
- echotest
- [root@localhost/dev/shm]
- #/dev/shm/x.sh
- -bash:/dev/shm/x.sh:Permissiondenied
- #修正/etc/fstab改动/dev/shm同享内存的nosuid与noexec值
- tmpfs/dev/shmtmpfsdefaults,nosuid,noexec,rw00
- mount-oremount/dev/shm/
欢迎大家来到仓酷云论坛! |