In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about the remedies for the erroneous implementation of chmod 777. * or chown-R * in Linux. Many people may not know much about it. In order to make you understand better, the editor summed up the following content for you. I hope you can get something from this article.
Mistakenly executed commands: chmod 777. * or chown-R *, etc., resulting in confusion of permissions in the entire operating system, and invalidation of some commands and devices. Do not restart at this time. The main way to change the permissions of each file back on it.
How can I restore the system files to the default state of the initial installation?
Principle: we install through pkgadd (pkgadd is recommended to install all package)
All files are recorded in detail in the / var/sadm/install/contents file.
The center of the following method is to use the records in this file to restore its state. Suppose your current id is root.
# cd / var/sadm/install
# redirect all lines in the contents file that do not contain the = (equal sign) or / devices to a new file contents.txt
# egrep-v "= | devices" contents > contents.txt
1. Deal with contents.txt. Extract 1, 4, 5, 6 columns and put them into another text.
Awk'{print $1, 4, 5, 6} 'contents.txt > contents.txt2
If this command goes wrong and the reason is "to many fields record number XXX", use the
Vi contents.txt
: g/SUNW/d
Use: instead of whitespace
Sed's / /: / g 'contents.txt2 > contents.txt3
2. Write a script to reset system permissions
# use vi to edit the following script file restore_perms
# vi restore_perms### # Begin #! / bin/bash for FILE in `cat / var/sadm/install/ contents.txt3`do FNAME= `echo $FILE | awk-F:'{print $1} '`PERM= `echo $FILE | awk-F:' {print $2} '`OWNR= `echo $FILE | awk -F:'{print $3} '`GRP= `echo $FILE | awk-F:' {print $4} '`echo "chown $OWNR:$GRP $FNAME" chown $OWNR:$GRP $FNAME echo "chmod $PERM $FNAME" chmod $PERM $FNAME done # rm contents.txt3 # End # Restore_perms script execution permission # chmod + x restore_perms # execute this script #. / restore_perms echo'/ opt/CTEact/kmdb/5.10/sparcv9:0755:bin:bin' | awk-F:'{print $1}'
After modification is completed, files with s-bit permissions need to be modified manually.
After reading the above, do you have any further understanding of the remedies for the erroneous execution of chmod 777.or chown-R * by Linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.