Fixmog equivalent for Linux

Posted on 2011-05-12
Last Modified: 2012-08-14

I’m working under Linux ReHat entreprise V5

I made a mistake and I changed erroneously all the permissions for the operating system

# cd /
# chmod –R 777 *

I known that Unix SCO have a command called fixmog for fix the permissions of the operating system. Do you know if there is something similar in Linux?

Thanks for your help,
Question by:alcani
    LVL 8

    Expert Comment


    Sorry about this.  But on the bright side you did not do a "rm -rf /"

    The rpm package management system in Red Hat has some builtin tools that should help you out.

    rpm --setperms <packagename>
    rpm --setugids <packagename>

    You have to do this one package at a time, but these rpm commands will check the files installed with the files from the rpm and if needed fix the permissions and user/group assignments.

    You probably want to write a script that asks the rpm database for each package installed and for each one run these two commands.

    This will not give you a 100% fix though.  Any file that was supposed to be installed by an rpm update and was given a new name so as not to mess with an existing file might not be caught by this approach because the new name is not actually part of the package inventory.

    If you need help with the script let me know, but this should get you what you want.

    LVL 38

    Accepted Solution

    As root
    for Package in `rpm -qa`; do rpm --setperms $Package; done
    LVL 10

    Assisted Solution

    To fix the permissions enter:

    for p in $(rpm -qa); do rpm --setperms $p; done

    To fix the group assignments:

    for p in $(rpm -qa); do rpm --setugids $p; done

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
    Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
    This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now