1. 如果/tmp是一个独立的磁盘分区,修改/etc/fstab文件中/tmp分区对应的挂载属性,加上nosuid、noexec、nodev三个选项即可
    LABEL=/tmp   /tmp          ext3    rw,nosuid,noexec,nodev   0 0 
    #nosuid、noexec、nodev选项表示不允许任何suid程序,在这个分区不能执行任何脚本等程序,以及不存在设备文件。

    在挂载属性设置完成后,重新挂载/tmp分区,保证设置生效。

  2. 对于/var/tmp,如果是独立分区,同样修改/etc/fstab文件即可;如果是/var分区下的一个目录,那么可以将/var/tmp目录下所有数据移动到/tmp分区下,然后在/var下做一个指向/tmp的软连接即可。也就是执行如下操作:
    [root@server ~]# mv /var/tmp/* /tmp  
    [root@server ~]# ln -s  /tmp /var/tmp
  3. 如果/tmp是根目录下的一个目录,那么设置稍微复杂,可以通过创建一个loopback文件系统来利用Linux内核的loopback特性将文件系统挂载到/tmp下,然后在挂载时指定限制加载选项即可
    [root@server ~]# dd if=/dev/zero of=/dev/tmpfs bs=1M count=10000 
    [root@server ~]# mke2fs -j /dev/tmpfs  
    [root@server ~]# cp -av /tmp /tmp.old  
    [root@server ~]# mount -o loop,noexec,nosuid,rw /dev/tmpfs /tmp  
    [root@server ~]# chmod 1777 /tmp  
    [root@server ~]# mv -f /tmp.old/* /tmp/  
    [root@server ~]# rm -rf /tmp.old

    编辑/etc/fstab,添加如下内容,以便系统在启动时自动加载loopback文件系统:

    /dev/tmpfs /tmp ext3 loop,nosuid,noexec,rw 0 0
  4. /dev/shm是一个共享内存设备,因此也可以通过修改/etc/fstab文件设置而实现,在默认情况下,/dev/shm通过defaults选项来加载,这样保证其安全性是不够的,需要修改/dev/shm的挂载属性,操作如下:
    tmpfs   /dev/shm    tmpfs   defaults,nosuid,noexec,rw  0 0
分类: 发行通用

10 条评论

wow888app · 2025-12-19 20:07

Downloaded the wow888app. Pretty slick interface! Everything is easy to find. Definitely worth a download if you’re into that sort of thing. Get the app here: wow888app

linhvaow88 · 2025-12-24 10:49

Alright, stumbled upon linhvaow88. Seems like they got some interesting stuff going on. I’ll be giving it a shot and see if it’s worth recommending! Here’s the Link: linhvaow88

jl10 casino · 2026-01-14 18:11

jl10 casino https://www.jl10-casino.net

slotphlogin · 2026-01-14 18:53

slotphlogin https://www.exslotphlogin.net

pin77 online · 2026-01-15 03:13

pin77 online https://www.pin77-online.com

9apisologin · 2026-01-25 03:34

9apisologin https://www.it9apisologin.com

peso88 · 2026-01-26 18:00

Peso88 Online Casino: Secure Login, Easy Register & App Download for the Best Slot Games in the Philippines. Join Peso88 Online Casino for the best gaming in the Philippines. Enjoy secure peso88 login, easy peso88 register, and peso88 app download. Play top peso88 slot games and win today! visit: peso88

phjoinlogin · 2026-01-31 14:06

Trying to get into phjoinlogin, the anticipation is killing me! Hope the registration process is easy. phjoinlogin

wowph11.com · 2026-01-31 14:06

Thinking of heading over to wowph11.com. Anyone got good or bad experiences to share? Lemme know! wowph11.com

2jl casino · 2026-01-31 14:07

Thinking about trying my luck at 2jl casino. Hoping the games are fun and the payouts are good! Worth a shot, right? 2jl casino

发表回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注