Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
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. –  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
add comment

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
add comment

Your Answer

 
discard

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.