How to secure /tmp and /var/tmp

Secure /tmp

  1. Edit /etc/fstab by typing the command nano -w /etc/fstab
  2. Paste the following at the bottom of /etc/stab that you just opened: none /tmp tmpfs nodev,nosuid,noexec 0 0
  3. Press ctrl + x to close the file, press y to save it.
  4. Remount /tmp by typing the following then press enter: mount -o remount /tmp
  5. You can verify that /tmp is correctly mounted by typing df -h and you should see something similar to the following: none          3.9G   0  3.9MG   0% /tmp.


Secure /var/tmp

  1. Backup /var/tmp by typing the following: mv /var/tmp /var/tmpbackup
  2. Make a symbolic link that makes /var/tmp point to /tmp by typing the following: ln -s /tmp /var/tmp
  3. Copy back the old data using the command: cp /var/tmpbackup/* /tmp/
  4. Remove the un-needed backup you created: rm -rf /var/tmpbackup

You should now reboot your VPS. This means /tmp and /var/tmp are now secured.

Was this answer helpful?

 Print this Article

Also Read

Prevent DDoS by using mod_evasive

“mod_evasive” is an evasive maneuvers module for Apache to provide evasive action in...

Is my server hacked? Lets check it with rootkit hunter

RookHit Hunter is a command-line utility that will search your machine for...

Installing and configuring Spamassassin on CentOS

If you run your own mail server you'll want it to run spam filtering software to reduce the...

How to increase numiptent limit?

You may got the following errors ( Most probably after enabling CSF ) The VPS iptables...

How to disable all Apache header information?

Follow the below steps to disable Apache header information. Edit your mail Apache configuration...