Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to restore the CentOS permission system

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to restore the CentOS permission system, the article is very detailed, has a certain reference value, interested friends must read it!

First of all, you must prepare a system that is the same as the failed machine, for example, you can install the same version of linux in the virtual machine.

Create a waynerQiu.c program in the new system as follows

# include

# include

Int list (const char * name, const struct stat * status, int type)

{

If (type = = FTW_NS)

Return 0

Printf ("% s 0% 3o\ n", name, status- > st_mode & 07777)

Return 0

}

Int main (int argc, char * argv [])

{

If (argc = = 1)

Ftw (., list, 1)

Else

Ftw (argv [1], list, 2)

Exit (0)

}

Then compile the file and export the permission information

# compiling

Gcc waynerQiu.c-o waynerQiu.com

# permission to execute and export related directories

. / waynerQiu.com / > > waynerQiu.txt

Copy the exported file to the faulty machine and execute the following script

#! / bin/sh

If [$#! = 1]

Then

Echo Usage: $0\

Exit

Fi

PERMFILE=$1

Cat $PERMFILE | while read LINE

Do

FILE= `echo $LINE | awk'{print $1}'`

PERM= `echo $LINE | awk'{print $2}'`

Chmod $PERM $FILE

# echo "chmod $PERM $FILE"

Done

Echo "change perm finished!"

You can save the script as a shell file such as mygod.sh

And then execute

Mygod.sh waynerQiu.txt

After the program is finished, restart the system to see if it has been restored.

The above is all the contents of the article "how to restore the CentOS permission system". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report