Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

I am unable to use sftp and mysql now.

share|improve this question
up vote 10 down vote accepted
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.

share|improve this answer
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. – troyengel Jan 1 '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 1 '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 1 '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. – troyengel Jan 2 '10 at 20:35

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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