I missinput a command in a directory (I don't remember what it is. Maybe it's in my home/user/, or in the / directory) in Ubuntu Linux.

sudo rm -f -r tmp

After that, when I restart and log in, I cannot login when I use that user. The system says some config file is missing for some apps I don't know in Gnome.

However, I can log in with user root.

Can I resolve the problem?


As root, do this:

# mkdir /tmp
# chmod o+t,ugo+rw /tmp
  • Worth noting that for selinux systems, you'll also want to run restorecon /tmp – miken32 Sep 30 '15 at 20:49

Thanks a lot Dennis Williamson! Just in order to make the answer more detailed:

While you are in the login screen, hit Ctrl+Alt+F1 (do it in the same order) to switch to the command mode interface. From there you can login with your username and passwrod. then run:

# sudo apt-get update
# sudo apt-get upgrade
# sudo rm -Rf /tmp
# mkdir /tmp #or if it didn't work run: sudo mkdir /tmp
# sudo chmod o+t,ugo+rw /tmp
# exit

Then restart your computer. It worked for me :)

You may also have a look here.

  • What is the deal with the apt-get update and apt-get upgrade? These commands have nothing to do with recreating the /tmp directory. – Mogget Oct 5 '15 at 23:49

I would like to add more information about this problem, since it bugged me for many hours. I would never imagine that directory /tmp is so important in Ubuntu.

You can also spot this problem if you open the file (/var/log/auth.log) and search for some lines similar to these:

Jan 18 01:55:12 localhost **gnome-keyring-daemon**[2016]: couldn't create socket directory: **Permission denied**
Jan 18 01:55:12 localhost gnome-keyring-daemon[2016]: couldn't bind to control socket: /tmp/keyring-mKRg6t/control: **No such file or directory**
Jan 18 01:55:12 localhost lightdm: pam_unix(lightdm:session): session closed for user <your_username>

This must have happened because you probably changed the permissions of directory /tmp. And this is why you could login with root and not with other users. As Dennis Williamson wrote this command (sudo chmod o+t,ugo+rw /tmp) sets the correct permissions (drwxrwxrwt)

Your Answer

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