1

By mistake I ran a stupid command with a typo in it. I created a user "teamspeak" and I wanted to change file owner of current directory and it's sub directories, but by mistake I ran it in the "/".

I was user "teamspeak" while I ran the command, not "root" and I ran something like this:

chown -r teamspeak:teamspeak /*

I seen many lines, the ones I was able to read were that it FAILED to change file owner, progress was around the /lib and maybe /boot when I pressed CTRL+C and stopped it.

But server doesn't become available after a restart (I am 90% sure is the file owner thing).

I am now about to boot it in rescue image mode that my host offers.

I was wondering if there is a way to revert the file permission thing.

AND/OR

A command to search for all files belonging to teamspeak:teamspeak and make them root:root

At least so I boot it properly and fetch all databases from my server.

adrianTNT
  • 1,252

5 Answers5

2

"A command to search for all files belonging to teamspeak:teamspeak and make them root:root"

Try

find / -user 'teamspeak' | xargs chown root:root
1

The problem is that changing the files/folders owner back to root may not solve all your problems as root is not the owner of all files/folders.

I think you have two options:

  1. Re-install the OS if possible.
  2. Go in the tedious task of comparing this with another running system and changing the owner as needed. You can start with changing the owner to root as an initial step.
Khaled
  • 37,789
1

The odd thing was that the OP apparently brought down the machine (or at least prevented reboot) by running a command as user "teamspeak" instead of root. This shouldn't happen, unless there were already permission issues on the box before the command was run.

Janne's answer won't work, since the changed files probably shouldn't be root owned to start with, but the idea of using find may be valid.

I don't know where adrianTNT is in his recovery process, but here's the sanity check/validation I would do:

1) run that find / -user teamspeak and get a list of changed files 2) compare this list to the file ownerships of a different CentOS box 3) if a different CentOS box is not available (or can't be brought up quickly enough), at least do an eyeball of the file list. Look for system files that have changed ownership.

I think you will still want to look at a different CentOS box once you have this list. As said, a chown by a non-privileged user should not screw up the box like that. It's possible there were permission issues prior to your mistake.

cjc
  • 25,492
1

The issue was fixed, a data center technician started it and said:

the machine was halted in the BIOS on an error, waiting for intervention.

I am waiting for more info but it was probably a booting warning because the /boot directory was set to another user than root:root

Now I got in ssh and ran find / -user 'teamspeak' to see the files with wrong user set, it was:

/mnt
/lib
/lost+found
/root
/etc
/lib64
/opt
/sbin
/var
/var/tmp/yum-teamspeak-6jBpFg
/usr
/boot
/home
/home/teamspeak
/home/teamspeak/.viminfo
/home/teamspeak/.bashrc
/home/teamspeak/.bash_profile
/home/teamspeak/.bash_logout
/home/teamspeak/.bash_history
/srv
/selinux
/tmp
/bin
/media

These are not many changed files/folders and result seems to include sub-directories too. So I compared them to another machine with same OS (CentOS 6), they were all supposed to be root:root , I changed them back, I did a reboot and it started nicely.

Pfew :)

adrianTNT
  • 1,252
0

If you don't have a backup the only solution that comes into my mind is to reinstall a server and never run that command again :D

You can still boot from the CD, mount the disk and recover the files you need.

Chris
  • 625