How to Undo Chgrp Command!?

Posted on 2008-10-08
Last Modified: 2013-11-15
Messed up.

I managed to chgrp on everything on my ubuntu webserver via SSH.

I wanted to chgrp recursively on all the files in the current directory I was issuing the command. Unfortunately it isnt relative and providing a '/' as the location sent the server off to change the group of every file on the server.

Needless to say, the server is now messed up... we cannot take orders on our website and we cannot receive emails. Theres probably many more implications that we have not found.

So the question is... how can this be fixed.

I have contacted our dedicated server provider and they are having trouble too... apparently the backup we pay for does not cover group permissions?  Strange.

So any one have any ideas of how to restore group permissions?  Owner permissions are still inatact.

Any thoughts appreciated.
Question by:manicwaszoot
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 19

Expert Comment

ID: 22668749
what did you change everything to?

You could change everything to `root`, ok it's not ideal but it may help you get out of a fix for a few minutes...
LVL 40

Expert Comment

ID: 22668783
can they provide you with a listing of the files and dir on the tapes / backups? what I understood from you is that you changed the group ownership and not the group permissions!

e.g. I took tar backup of my home dir then did

tar -tvf tarfile

and got something like

drwxr-xr-x omar/omar         0 2007-11-24 09:13 ./.config/
-rw-r--r-- omar/omar         5 2007-11-24 09:13 ./.config/user-dirs.locale
-rw------- omar/omar       631 2007-11-24 09:13 ./.config/user-dirs.dirs
-rw------- omar/omar      1991 2008-10-07 20:27 ./.bash_history
-rw------- omar/omar       256 2007-11-24 09:13 ./.pulse-cookie
-rw-r--r-- omar/omar       124 2007-08-31 18:20 ./.bashrc
drwx------ omar/omar         0 2007-11-24 09:13 ./.gnome2_private/
drwxr-xr-x omar/omar         0 2008-06-02 16:44 ./.wapi/
drwxrwsrwx omar/omar         0 2008-04-26 16:15 ./test/
-rw-rw-r-- omar/omar         0 2008-04-26 16:14 ./test/f
-rw-rw-r-- omar/omar         0 2008-04-26 16:15 ./test/ff
drwxr-xr-x omar/omar         0 2007-11-24 09:13 ./Videos/
-rw-rw-r-- omar/omar       131 2008-06-02 16:37 ./.gtk-bookmarks
LVL 19

Expert Comment

ID: 22668806
For info, there is no `undo` command, it would probably need to be done manually.

If this was Redhat or another rpm based install I'd write a script from the query package information to rebuild the owner/group information, alas I've no idea what the equivalent apt-get commands would be to list the information.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 20

Assisted Solution

edster9999 earned 166 total points
ID: 22668889
I would perform a backup of the data on the server(s) and then a fresh install.
This will get the rights / owners back on all the software.
Putting the group owners back on the data should be far easier.
LVL 40

Expert Comment

ID: 22668918
Hi jools,

the problem is not only with the group ownership of installed packages files and directories, it includes those created and developed in house. But your idea will be good and will help to some extent to get a working system.
LVL 19

Expert Comment

ID: 22668957
Thx Omar, absolutely agree...

I was a little concerned when manic said the server was messed up and they couldnt take orders or send email... not good for the job prospects!

Do you know apt-get? I'm a little rusty.

Like the idea about the tar btw, could knock up another script for that too!
LVL 40

Accepted Solution

omarfarid earned 167 total points
ID: 22669363
LVL 19

Expert Comment

ID: 22669479
I guess we need more feedback from manic.

I'm wondering if dpkg can be used to list all the packages installed on the system and also all the files with permissions on the system, we could then sort out a quick script to strip out the information and run a chgrp on the lot.

LVL 40

Expert Comment

ID: 22669706
is rpm available on your system?

Author Comment

ID: 22669731
Thanks for the comments...

The email is back up but we have closed shop, with the rest of the site working bar checkout.

We have opted to migrate to a new server, which has a fresh build. The server is an upgrade so thats something I suppose.

We will then move the site data across with correct permissions from the backup.

So the worst of it is, no online orders for a number of hours.

Who would of thought chgrp command could wreak such havoc. It would be nice if there was a 'Are you sure you wish to ....'  prompt before executing...   I realised just after I hit enter that I may be chgrp'ing more than I intended.

Not a good day!

So, in order to learn from mistakes and take measures to stop this happening again. How can I back up all the files on my new server once I have finished setting it up?  I dont trust the way our provider does backups anymore.  Can you backup everything into a TAR, keeping all Group and Owner permissions?

LVL 19

Assisted Solution

jools earned 167 total points
ID: 22669807
> It would be nice if there was a 'Are you sure you wish to ....'  prompt before executing...  

Yup, we've all wondered that just after we press enter sometimes!

> Can you backup everything into a TAR, keeping all Group and Owner permissions?

Yes... tar cvf <device_or_file> <directory>
man tar for more info.

You could create aliases for chgrp and chown to run a script if you want a bit more work....
LVL 40

Expert Comment

ID: 22669810
Yes , tar can do that and check the man page of tar on your system (man tar) for -p option.

It will be nice that you do periodical backup to a stand by system (if have cash for that).

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question