Solved

How to Undo Chgrp Command!?

Posted on 2008-10-08
12
1,265 Views
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.
0
Comment
Question by:manicwaszoot
12 Comments
 
LVL 19

Expert Comment

by:jools
Comment Utility
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
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
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
 
LVL 19

Expert Comment

by:jools
Comment Utility
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
 
LVL 20

Assisted Solution

by:edster9999
edster9999 earned 166 total points
Comment Utility
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
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
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
 
LVL 19

Expert Comment

by:jools
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 40

Accepted Solution

by:
omarfarid earned 167 total points
Comment Utility
0
 
LVL 19

Expert Comment

by:jools
Comment Utility
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
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
is rpm available on your system?
0
 

Author Comment

by:manicwaszoot
Comment Utility
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
 
LVL 19

Assisted Solution

by:jools
jools earned 167 total points
Comment Utility
> 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
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
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

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now