r/linux•
AaronOpfer

A friendly reminder to have backups :)

So I'm at work and I'm trying to add a ticketing system to our server machine. Most of our day-to-day files are stored on this machine. In order to install trac I needed to create some folders, no big deal.

aopfer@box:/home$ sudo mkdir SVNs

Next I saw that I needed to make the directory readable by the www-data user in order for it to be readable by apache. I didn't want the directory to be world-readable however so instead I had to change the ownership of the folder. I said, okay, no problem!

aopfer@box:/home$ cd SVNs
aopfer@box:/home/SVNs$ ls -alh SVNs
ls: cannot access SVNs: No such file or directory
aopfer@box:/home/SVNs$ cd ..
aopfer@box:/home$ ls -alh SVNs
total 8.0K
drwxr-xr-x  2 root     root    4.0K Dec 28 20:08 .
drwxr-xr-x  2 root     root    4.0K Dec 28 20:08 ..
aopfer@box:/home$ sudo chown -R www-data:mygroup .

Alas, I tricked myself into thinking I was still in the SVNs directory, and just like that I reset all of the ownership of every single file for all my home directories. Shit! Immediately my coworker behind me had all his desktop icons disappear because they were stored on the server (using folder redirection)!

Thankfully, I had a backup NAS (A Dlink DNS-323) that I modified the firmware of, so I was able to recover my home directory ownership by SSHing into it and using ls -alh to list all the directories' owners. Then I went through the 20 or so directories and set their owners back using chown -R. Phew. What would have been a hellish time trying to re-figure out what groups and users should own what folders, I got everything back to normal in five minutes. Granted, I probably did nuke all of the file ownership information that could have been useful for auditing, but at least I didn't kill the business.

What close calls has r/linux had?

Posted Dec 29, 2011, 1:19 AM UTC

7052
Loading comments…