Recreate the /tmp directory on its own partition

 

IMPORTANT NOTE:  This document is based on CentOS, RedHat Linux 7.3 and Enterprise.  The concepts should be similar across operating systems, but the commands will very likely be different.  Also, never assume the directory structures exist in your system as written in the document.  Never blindly follow security instructions -- read, review, compare, apply as it fits your system.

Log onto the server as root:

Is the /tmp directory in its own partition?

    1. Do a “df –k”

Do you see a /tmp partition?  If YES, then move to step B; otherwise move to step C.

    1. Modify etc fstab to change the definition for /tmp

Change “defaults” to “rw,nosuid,noexec” and save etc fstab

Save the file, and execute the following command:

mount -oremount loop,rw,nosuid,noexec /tmp

Skip to step E

    1. The following will create a 100 MB /tmp directory on its own partition with noexec and nosuid.

      IMPORTANT:On CentOS and RedHat Enterprise 4.x, use /var or another partition with a large amount of free space rather than /dev as CentOS 4.x recreates the /dev partition every time the server reboots; also, CentOS 4.x and RedHat Enterprise 4.x, do not use the "loop" parameter above.

cd /dev/

dd if=/dev/zero of=Tmp bs=1024 count=100000

mkfs -t ext3 /dev/Tmp

cd /

cp -aR  /tmp  /tmp_backup

mount  -o  loop,noexec,nosuid,rw  /dev/Tmp  /tmp

cp -aR /tmp_backup/* /tmp/

chmod 0777 /tmp

chmod +t  /tmp

    1. Modify etc fstab to add the definition for /tmp

/dev/Tmp          /tmp          ext3          loop,rw,nosuid,noexec     0 0

    1. Link /var/tmp to /tmp

cd /var

Verify /var/tmp is empty

rm -fR /var/tmp

ln -s /tmp /var/tmp

NOTES:

The  etc fstab entry means it will be mounted automatically on boot up.

nosuid, noexec are to help protect against hackers putting root kits in /tmp and building / executing them

IMPORTANT NOTE:  This document and all linked document is being provided as a good will gesture to the Parallels H-Sphere community and to others who may benefit from its use.  Dynamic Net, Inc. makes no representations implied or explicit as to their value or warranty. Dynamic Net, Inc. will not be held liable for any damage resulting in the application of the steps and procedures noted.  If you feel uncomfortable at all about doing any of the steps, make a complete system backup and hire a third party like We Manage Servers to do the work for you.

 

 
 

Home ::  About :: Testimonials  ::  Articles ::  Employment ::  Contact
Services ::  Web Hosting ::  Managed Services :: Parallels H-Sphere  :: Monitoring :: ShopSite 
Resellers
::   Program ::  Compare Plans ::  Private Label
   
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 Legal Notices - Acceptable Use Policy, Contract, Copyright, Terms of Service

See our
privacy statement for questions on how we use information gained by our site.

Managed Services provided by We Manage Servers