How to Restore Deleted /tmp Directory in Linux

The /tmp directory contains mostly files that are required temporarily, it is used by different programs to create lock files and for temporary storage of data. Many of these files are important for currently running programs and deleting them may result in a system crash.

On all if not most Linux systems, the contents of the /tmp directory are deleted (cleared out) at boot time or at shutdown by the local system. This is a standard procedure for system administration, to reduce the amount of storage space used (typically, on a disk drive).

Important: Do not delete files from the /tmp directory unless you know exactly what you are doing! In multi-user systems, this can potentially remove active files, disrupting users activities (via programs they are using).

What if you accidentally delete the /tmp directory? In this article, we will show you how to restore (recreate) /tmp directory after deleting it.

Suggested Read: How to Recover Deleted Files in Linux

A few things to note before running the commands below.

  • the /tmp must belong to the root user.
  • set appropriate permissions that will allow all users to use this directory (make it public).
$ sudo mkdir /tmp 
$ sudo chmod 1777 /tmp

Alternatively, run this command.

$ sudo mkdir -m 1777 /tmp

Now run the command below to check the permissions of the directory.

$ ls -ld /tmp
Restore Deleted /tmp Directory in Linux
Restore Deleted /tmp Directory in Linux

The permission set here mean everybody (owner, group and others) can read, write and access files in the directory, and the t (sticky bit), implying files may only be deleted by their owner.

Note: Once you have restored the /tmp directory as shown above, it is recommended you reboot the system to ensure that all programs start operating normally.

That’s it! In this article, we showed how to restore (recreate) /tmp directory after deleting it accidentally in Linux. Drop your comments via the feedback form below.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

10 thoughts on “How to Restore Deleted /tmp Directory in Linux”

      • /tmp/fluxspace/client.txt files and /tmp/fluxspace/hit.txt files are missing in my Linux . Though I’m not able to perform an evil twin attack. I’m using Debian Linux as a live OS. Please help. TAKE IT AS A CHALLENGE. Please help

  1. AWESOME information!….This will definitely come in handy for me…..since I’m constantly installing / removing Linux distros, and sometimes I make that mistake of deleting the wrong thing! Thanks for such a great, informative article!!


Leave a Reply to hltdev Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

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