Tmp folder deleted?

September 22, 2016 211 views
Python Django

So i have a problem.

In order to free space from disk, i deleted my tmp folder, and then created another one. But when logging via ssh to my droplet, it promps this:

mktemp: failed to create file via template `/tmp/virtualenvwrapper-initialize-hook-XXXXXXXXXX': Permission denied
ERROR: virtualenvwrapper could not create a temporary file name.

How do I solve this?


2 Answers
xMudrii September 22, 2016
Accepted Answer


You should verify permissions of your /tmp folder.
Execute following command, it will return information about permissions and ownership:

  • ls -ld /tmp

Default out should be that it have 1777 - drwxrwxrwt permissions and ownership is set to root:root.

ls -ld /tmp
drwxrwxrwt 11 root root 20480 Sep 22 09:35 /tmp

If this is not the case, two simple command could help you:

  • sudo chmod 1777 /tmp
  • sudo chown root:root /tmp

Permissions explained:
1 is sticky bit. When set, only owner of file can rename or delete it.
777 means that owner, group and everyone else can read, write and execute.
So adding sticky bit to 777 -> 1777 would ensure only you can remove/rename files which you are owner

Have another answer? Share your knowledge.