Book Image

Troubleshooting CentOS

By : Jonathan Hobson
Book Image

Troubleshooting CentOS

By: Jonathan Hobson

Overview of this book

Table of Contents (17 chapters)
Troubleshooting CentOS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Restoring file and directory permissions


File and directory permissions are important, and to view the current state of all the files in a particular directory, you can run the following command:

# ll

Alternatively, you can target a particular directory by running:

# ll /path/to/directory

However, in a situation where someone has mistakenly changed the permissions of a particular system-based file or folder this calamitous situation can be rectified with the following RPM-based commands:

# rpm --setugids PACKAGENAME
# rpm --setperms PACKAGENAME

On the other hand, should it be the case that an entire directory has been mistakenly updated with chown or the chmod commands, the following commands will prove more useful:

# for package in $(rpm -qa); do rpm --setugids $package; done
# for package in $(rpm -qa); do rpm --setperms $package; done

Based on the commands shown preceding, the first command will serve to reset all the file and folder ownerships values to the default state, while the second...