Accidentally run chown -R user /*

I accidentally did run chown -R my_username /* instead of chown -R my_username ./*, so how do I undo this? Can I simply run chown -R root /* and then chown -R my_username /home/my_username?

EDIT: The installation is pretty fresh. I installed this system couple of days ago and it doesn't have any other users yet than "my_username".
 
I accidentally did run chown -R my_username /* instead of chown -R my_username ./*,
Ouch. It could be worse though, I once did rm -rf * thinking I was in /usr/ports. I wasn't. It was /usr :eek:

so how do I undo this
It depends on how far it extends but this should fix most of it:
Code:
mtree -e -p / -U -f /etc/mtree/BSD.root.dist
mtree -e -p /var -U -f /etc/mtree/BSD.var.dist
mtree -e -p /usr -U -f /etc/mtree/BSD.usr.dist

There are a few more files in /etc/mtree that might be needed, mtree(8) is a little cryptic but extremely useful.
 
Ouch. It could be worse though, I once did rm -rf * thinking I was in /usr/ports. I wasn't. It was /usr :eek:


It depends on how far it extends but this should fix most of it:
Code:
mtree -e -p / -U -f /etc/mtree/BSD.root.dist
mtree -e -p /var -U -f /etc/mtree/BSD.var.dist
mtree -e -p /usr -U -f /etc/mtree/BSD.usr.dist
The command did go through the whole system.
 
For /usr/local/ most of it should be chown -R root /usr/local. You may have some services installed that have files/directories in /usr/local/etc/ that should be owned by a specific user account instead though. But those are easy enough to identify.
 
Suggestion that's more thorough than educated guesses, and perhaps a little less work than a full reinstall: Find a sacrificial machine, and install a virgin FreeBSD setup on it. Then use the find command to find things that are not used by root: find / \! -user root. Now, this will give you many hundreds or many thousands of hits. To make that list more manageable, try to find directories, and stop at the top level directory: find / \! -user root -type d -prune. On my home system, this finds 62 directories not owned by root (excluding /home). Fixing those should get you pretty close.

An ideal solution would be to use the virgin system, and make a complete list of all files (with user and group), and then use that list to check all the files on your production system. That would probably be half hour of script writing.
 
SirDice I once did the same thing. Fortunately, it was a completely fresh install. This was back with FreeBSD-4.x when one routinely ran chflgs then removed /usr/obj. I though I was in /usr/obj. Then ran cd /usr/src and got no such directory or similar.

I think everyone's done similar, like a dd with of= being the wrong place, etc.
 
I remember when Gentoo was very new, and I did the editing of something. Probably make.conf I wasn't used to nano and put :x at the end of the file, vi habit. I was the first to publicly admit it on the Gentoo mailing list at the time, and after my confession, (like you 2 days compiling or possibly 3--I think I used KDE at that time), lots of other people admitted they'd done the same thing. For those who don't remember, when Gentoo first came out, its stage one install, which involved compiling the whole system, only included nano, not vi.
 
Yep, I've done similar. It ~is~ a rite of passage, isn't it. FreeBSD (and all Unix variants for that matter) expect you meant to enter whatever you typed, no "are you sure" business. You get used to that.
 
General statement: There are two kinds of people. Those who have really good backups, and those who have not lost data yet.

And the largest source of data loss is user error, with accidental deletion as #1. It is soon followed by mistakes made by service personnel. In storage systems, the classic error (happens all the time): In a redundant disk array, one disk fails. This is not an emergency, because we have redundancy, and the array continued functioning. A field service person is sent, or the admin goes to fix it. Too often, they leave the dead disk in the system, and pull a functioning disk out instead, throw it in the trash, and put a blank disk in. And unless you have high degrees of redundancy, you now have data loss.

This then leads to my advice for how to administer a computer system: You hire a person and a dog. The person is there to feed the dog. The dog is there to bite the person, if they try to touch the computer.
 
Back
Top