Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I accidentally run the following command as root chown mike -Rf / backups the point is that I added a space between / and backups my mistake, I stopped the command after 1-2 seconds, how can I recover from this? I have problems with DirectAdmin right now for example when accessing it I recive the error:

Unable to determine Usertype
user.conf needs to be repaired

Or I stopped recieving emails, I dont even know what else is messed up right now...

share|improve this question
Since it sounds like you have backups, I suggest comparing ownership info with the backups. – derobert May 1 '13 at 15:53
Note that the chown may also have cleared any setuid or setgid bits on the affected files, even if they were originally owned by root. – Keith Thompson May 1 '13 at 22:25
up vote 3 down vote accepted

There is no way to change this back without reverting to your backup as the system does not keep track of revision of ownership.

Best is to make a backup now, so any further changes can be rolled back.

Reinstalling the packages on your system probably resolves most of the ownership problems. On Debian/Ubuntu I would do:

apt-get install --reinstall package

on an rpm based system something like rpm -Uvh --force package.rpm for anything that is giving trouble. If properly setup a package will not overwrite configuration files that you changed.

If you have another similar system, or a backup you can retrieve original ownership information from that an apply to your system. First make list of files and directories you are interested in using:

find / -user mike

and use that list to find not-mike-owned files in the backup or similar system.

share|improve this answer
I suggest you to check this answer about package reinstallation under a Debian based system. – Totor May 1 '13 at 23:09

I'm afraid that the only solution you have is to compare with another installation of the same distribution and reset the owners correctly.

share|improve this answer

That depends on the OS you are running.

If it is Solaris 10 and older, you can fix all the owner issues affecting files and directories belonging to a package with the following command:

pkgchk -f

With Solaris 11, that would be:

pkg fix

I believe AIX has a similar package fix command.

If you run a rpm based OS (Red Hat, Fedora and the likes), you should be able to run

rpm -aV

to detect the files and directories with discrepancies against the package database. You might then fix them by running:

rpm --setugids <package-name>

But you would need to pass each affected package name. Alternatively, you might simply run:

for package in $(rpm -qa); do rpm --setugids $package; done

If you are running a debian based OS, I'm afraid file ownership isn't stored in the package database so you would need to either use your backup if any as a reference to restore the ownership, or find a similar system for the same.

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.