In this article, we have present a solution to the problem "Unable to make temporary file: Permission denied". The solution is to set the correct file permissions in /tmp directory. This is a critical problem as using sudo in command does not work.
Table of contents:
Replicate the error:
Assume you have a code "code.cc" which creates a file in the temporary directory /tmp. You will get the error if the /tmp directory does not have right permissions.
Unable to make temporary file: Permission denied
This can come if:
- You deleted /tmp and recreated it with default parameters like
Using sudo to run your code will not solve the issue.
To fix the issue, run the following command in terminal:
sudo chmod -R 1777 /tmp
- 1 = sticky bit
- 7 = Read + Write + Execute
With this article at OpenGenus, you must be able to fix this issue.