Is it a possible hole of security having /tmp/ folder under user owner instead of root?

I have set it temporally under my user by mistake, after that its impossible to bring it back to root user: Ubuntu after that doesent recognize my session.


I don't think there's an inherent risk if /tmp doesn't belong to root, but it should belong to root following best practices (it's a system directory).

Also, note that the /tmp directory permissions must have the sticky bit set:

drwxrwxrwt  4 root root  4096 2012-02-19 19:56 tmp

This way, files created in /tmp can be read and written only by the user that creates them. Not doing this is indeed a security risk as users could write or delete files that belong to other users or processes.

Regarding your session, I believe you should be able to solve this by changing the ownership from a console, while the X system is down (go to a TTY console with CTRL+ALT+F1, service lightdm stop (or service gdm stop), change ownership and reboot).

To change owner and permissions, you can use:

sudo chown root:root /tmp
sudo chmod 1777 /tmp
  • my folder tmp/ is actually : drwxrwxr-x 13 papachan root 4096 2012-02-19 14:23 tmp actually iam able to resolve the session problem by starting Reconvery console and change my user PASSWD – Papachan Feb 19 '12 at 19:41
  • maybe the problem session is another problem... now my /tmp folder belong to root user and with the correct permissions as you mentioned. and i can login to my session – Papachan Feb 19 '12 at 19:45
  • 1
    I updated my answer with the commands you can use to fix this. Make sure you reboot after the changes: in this case you want to be sure that everything remains correct after rebooting. – jjmontes Feb 19 '12 at 19:46
  • His session problem was the strange permissions on /tmp that caused explosion after changing owner back to root. – Joshua Jul 22 '16 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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