Solved

How to Undo Chgrp Command!?

Posted on 2008-10-08
12
1,375 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
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...
0
 
LVL 40

Expert Comment

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

Expert Comment

by:jools
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.
0
 
LVL 20

Assisted Solution

by:edster9999
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.
0
 
LVL 40

Expert Comment

by:omarfarid
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.
0
 
LVL 19

Expert Comment

by:jools
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!
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 40

Accepted Solution

by:
omarfarid earned 167 total points
ID: 22669363
0
 
LVL 19

Expert Comment

by:jools
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.

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22669706
is rpm available on your system?
0
 

Author Comment

by:manicwaszoot
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?

0
 
LVL 19

Assisted Solution

by:jools
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....
0
 
LVL 40

Expert Comment

by:omarfarid
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).
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now