14

i was trying to run

sudo rm -r ./tmp

but instead typed

sudo rm -r /tmp

Will it be fixed by running?

sudo mkdir /tmp

if i do what permissions should i give it?

ps: i didnt log out of my system yet

25

I can't think of a reason why this shouldn't work. On my system, the permissions are set by:

sudo chmod 1777 /tmp

(drwxrwxrwxt)

  • I rebooted my system after deleting the /tmp folder and now it is not getting past lightdm. – Juzer Ali Dec 5 '12 at 4:49
8

You should run the following commands to restore the tmp folder.

sudo -i
# You now have a root prompt and do not need to continue typing sudo
mkdir /tmp
chmod 1777 /tmp
exit

Then you sould be all good

  • 1
    I think that exiting the root prompt after the steps would be worth mentioning. – zxcdw Aug 22 '12 at 0:34
4

To add to Alex's answer, you can do both those commands at the same time using the -m or --mode option for mkdir(1), which specifies the mode for the created directory:

-m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask

So the command would be:

sudo mkdir -m 1777 /tmp
-1

A reboot of the system will fix it up automatically, in case if you have issues with rebooting the system use sudo mkdir -m 1777 /tmp should work fine as mentioned in other answers.

  • 1
    Duplicate of accepted answer. – Fabby Dec 4 '18 at 7:23
  • Not really - this one uniquely suggests that rebooting will fix – Zanna Dec 4 '18 at 10:54
  • 1
    And how will the user issue that command if they have trouble rebooting? – Elder Geek Dec 7 '18 at 17:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.