Deleted the \tmp folder and receiving “bash: cannot create temp file for here-document: Permission denied” Error

I was trying to delete ~/tmp folder and accidentally deleted the /tmp folder. Then when I tried to ls a folder structure I kept getting this error:

bash: cannot create temp file for here-document: Permission denied

To fix the error I ran the following commands:

1
2
3
4
5
6
7
cd /

mkdir tmp

sudo chown root:root /tmp

sudo chmod 1777 /tmp

 

Leave a Reply

Your email address will not be published. Required fields are marked *

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