Restore Deleted tmp Folder in Linux Ubuntu

How to restore deleted tmp folder in Linux Ubuntu. On Linux, recover tmp files using the following method.

/tmp directory contains mostly files that are required temporarily. Many programs use this to create lock files and for temporary storage of data. Do not remove files from this directory unless you know exactly what you are doing! Many of these files are important for currently running programs and deleting them may result in a system crash. Usually it won’t contain more than a few KB anyway. On most systems, this directory is cleared out at boot or at shutdown by the local system. The basis for this was historical precedent and common practice. However, it was not made a requirement because system administration is not within the scope of the FSSTND. For this reason people and programs must not assume that any files or directories in /tmp are preserved between invocations of the program.

Please note that the /var/tmp folder is different from the /tmp directory. The /var/tmp contains the temporary files preserved between system reboots. It is made available for programs and applications which require temporary files or directories preserved between system reboots.

Restore /tmp Directory

All the contains of the /tmp directory, files and directories must not be deleted. /tmp can be recreated. All you have to do is to give it to root (chown root:root /tmp) and permissions set to 1777. This will allow everyone to use the directory. The permission 1777 is eual to rwxrwxrwt. Which means anyone can read, write and access files in the said directory. Also note the letter t which ensures that the contenet can only be deleted by the owner.

To restore the deleted /tmp directory, run the following command:

$ sudo mkdir /tmp
$ sudo chmod 1777 /tmp

or

$ sudo mkdir /tmp && sudo chmod 1777 /tmp

Make a note that while performing the said operation, /tmp must have root privileges. I would also recommend to reboot the system.

Restore Deleted tmp Folder in Linux Ubuntu originally posted on Source Digit – Latest Technology, Gadgets & Gizmos.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.