2

Can anyone tell me how I can undo a sudo rm -r /var/run mistake?

I am unable to use sftp and mysql now.

Wesley
  • 32,690
  • 9
  • 82
  • 117

2 Answers2

10
mkdir /var/run
chmod 755 /var/run

that will fix most things, anything that still doesn't work will just need to be restarted

edit: restarted as in, /etc/init.d/ssh restart which will recreate /var/run/sshd. you may have some issues with the pid files being missing, nothing a manual pkill won't fix.

Justin
  • 3,856
  • 18
  • 21
  • 1
    The cron, at, acpi and DBUS subsystems usually work out of /var/run/ in realtime as well, so you might restart those systems. Realistically a full reboot after the above would do you better, you're missing a lof of PID files now. –  Jan 01 '10 at 17:21
  • There is no harm in missing a .pid file, it will just potentially cause the init script to fail when shutting down(so there is no point in rebooting just to fix that) Cron and at should be fine, acpid and dbus (and mysql) would break because they use sockets. Being a server it probably doesn't have dbus and acpid can easily be restarted.. – Justin Jan 01 '10 at 17:33
  • @Justin: Have you seen the number of things which use dbus these days? It's ridiculous. There's a good chance that it's running, even on a server machine. – womble Jan 01 '10 at 23:05
  • My servers use dbus. Not having PID files means all sorts of things could break, such as Apache log rotations, syslog rotations and anything else that tries to look for the master PID of a running process to send it a HUP (sic) during the course of it's lifespan. At the point you've accidentally whacked /var/run/ you should be prepared for a reboot to fix it anyways. –  Jan 02 '10 at 20:35
0

It depends. On certain file-system types, it is possible to do an undelete and recover earlier data such as for reiserfs but it may not work for other file-systems. However, your mileage may vary.

If it is a matter of getting some applications to work, you may succeed by re-installing some of them and re-starting others.

sybreon
  • 7,405
  • 1
  • 21
  • 20