Tmp directory deleted, I cannot login to the system

3

4

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?

user2195

Posted 2011-02-05T08:18:47.393

Reputation:

Answers

9

As root, do this:

# mkdir /tmp
# chmod o+t,ugo+rw /tmp

Paused until further notice.

Posted 2011-02-05T08:18:47.393

Reputation: 86 075

Worth noting that for selinux systems, you'll also want to run restorecon /tmp – miken32 – 2015-09-30T20:49:01.583

3

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.

Ali

Posted 2011-02-05T08:18:47.393

Reputation: 31

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 – 2015-10-05T23:49:17.607

1

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)

s1c

Posted 2011-02-05T08:18:47.393

Reputation: 11