How to Undo Chgrp Command!?

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.
manicwaszootAsked:
Who is Participating?
 
joolsCommented:
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...
0
 
omarfaridCommented:
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
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
joolsCommented:
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.
0
 
edster9999Connect With a Mentor Commented:
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.
0
 
omarfaridCommented:
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.
0
 
joolsCommented:
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!
0
 
joolsCommented:
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.

0
 
omarfaridCommented:
is rpm available on your system?
0
 
manicwaszootAuthor Commented:
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?

0
 
joolsConnect With a Mentor Commented:
> 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....
0
 
omarfaridCommented:
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).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.