{"id":12595,"date":"2019-03-28T02:50:43","date_gmt":"2019-03-28T02:50:43","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12595"},"modified":"2019-03-28T02:50:43","modified_gmt":"2019-03-28T02:50:43","slug":"how-to-restore-deleted-tmp-directory-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/how-to-restore-deleted-tmp-directory-in-linux\/","title":{"rendered":"How to Restore Deleted \/tmp Directory in Linux"},"content":{"rendered":"<p>The\u00a0<code>\/tmp<\/code>\u00a0directory 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.<\/p>\n<p>On all if not most Linux systems, the contents of the\u00a0<code>\/tmp<\/code>\u00a0directory are deleted (cleared out) at boot time or at shutdown by the local system. This is a standard procedure for system administration, to\u00a0<a href=\"https:\/\/www.tecmint.com\/fslint-find-and-remove-duplicate-unwanted-files-in-linux\/\" target=\"_blank\" rel=\"noopener\">reduce the amount of storage space<\/a>\u00a0used (typically, on a disk drive).<\/p>\n<p><strong>Important<\/strong>: Do not delete files from the\u00a0<code>\/tmp<\/code>\u00a0directory 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).<\/p>\n<p>What if you accidentally delete the\u00a0<code>\/tmp<\/code>\u00a0directory? In this article, we will show you how to restore (recreate)\u00a0<code>\/tmp<\/code>\u00a0directory after deleting it.<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/recover-deleted-file-in-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Recover Deleted Files in Linux<\/a><\/p>\n<p>A few things to note before running the commands below.<\/p>\n<ul>\n<li>the\u00a0<strong>\/tmp<\/strong>\u00a0must belong to the root user.<\/li>\n<li>set appropriate permissions that will allow all users to use this directory (make it public).<\/li>\n<\/ul>\n<pre>$ sudo mkdir \/tmp \r\n$ sudo chmod 1777 \/tmp\r\n<\/pre>\n<p>Alternatively, run this command.<\/p>\n<pre>$ sudo mkdir -m 1777 \/tmp\r\n<\/pre>\n<p>Now run the command below to check the permissions of the directory.<\/p>\n<pre>$ ls -ld \/tmp\r\n<\/pre>\n<div id=\"attachment_25508\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/04\/Restore-tmp-Directory-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-25508\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/04\/Restore-tmp-Directory-in-Linux.png\" alt=\"Restore Deleted \/tmp Directory in Linux\" width=\"500\" height=\"71\" aria-describedby=\"caption-attachment-25508\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-25508\" class=\"wp-caption-text\">Restore Deleted \/tmp Directory in Linux<\/p>\n<\/div>\n<p>The permission set here mean everybody (owner, group and others) can read, write and access files in the directory, and the\u00a0<code>t<\/code>\u00a0(sticky bit), implying files may only be deleted by their owner.<\/p>\n<p><strong>Note<\/strong>: Once you have restored the\u00a0<code>\/tmp<\/code>\u00a0directory as shown above, it is recommended you\u00a0<strong>reboot<\/strong>\u00a0the system to ensure that all programs start operating normally.<\/p>\n<p>That\u2019s it! In this article, we showed how to restore (recreate)\u00a0<strong>\/tmp<\/strong>\u00a0directory after deleting it accidentally in Linux. Drop your comments via the feedback form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/restore-deleted-tmp-directory-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The\u00a0\/tmp\u00a0directory 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\u00a0\/tmp\u00a0directory are &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/how-to-restore-deleted-tmp-directory-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Restore Deleted \/tmp Directory in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12595","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12595"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12595\/revisions"}],"predecessor-version":[{"id":12596,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12595\/revisions\/12596"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}