Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux system misoperation execution: chmod-R 777 / later repair method

Shulou Source: shulou.com Published: 2022-06-02 05:10:02 09月25日 Update

Accidental misoperation: chmod-R 777! It's over? Modified all file permissions of the Linux system, for reference only!

Linux system has no operation to execute: repair method after chmod-R 777:

1) do not exit the current login window after execution!

If you cannot log in to ssh, it should have something to do with the files passwd, group, shadow and ssh. Open another linux to view the permissions and modify them to the corresponding permissions on the wrong machine:

Cd / etc

Chmod 644 passwd group shadow

Chmod 400 gshadow

Cd ssh

Chmod 600 moduli ssh_host_dsa_key ssh_host_key ssh_host_rsa_key

Chmod 644 ssh_config ssh_host_dsa_key.pub ssh_host_key.pub ssh_host_rsa_key.pub

Chmod 640 sshd_config

Service sshd restart restarts the sshd service

Test reconnecting to ssh to see if the connection can be successful until the connection is successful

2)

Find a linux system (as clean as possible), export the permissions of the system, and then import it into this machine.

Execute on a good machine

Cd /

Getfacl-R / > linux.chmod.txt

Then upload it to the machine to be repaired by ftp or rz command

Execute:

Cd /

Setfacl-restore=linux.chmod.txt

Check directly: whether the permission is normal! Abnormal execution again, check again to see if it is normal!

If it is not executed in the / directory and the result does not take effect, you will probably need reboot! All recommended export and import operations under the root / directory

If it is not normal, you can do the following before trying reboot,reboot again:

Mkdir-p / root/sh

Cd / root/sh/

Vi sshtmp.sh

#-start-

Sleep 300

Cd / etc

Chmod 644 passwd group shadow

Chmod 400 gshadow

Cd ssh

Chmod 600 moduli ssh_host_dsa_key ssh_host_key ssh_host_rsa_key

Chmod 644 ssh_config ssh_host_dsa_key.pub ssh_host_key.pub ssh_host_rsa_key.pub

Chmod 640 sshd_config

Chmod upright s `which su`

Chmod 755`which passwd`

Chmod Ubuns `which passwd`

Service sshd restart

#-end-

Put it on and start it up

Echo'/ root/sh/sshtmp.sh &'> > / etc/rc.local

And then reboot.

If you can log in to the system normally after reboot, you can first kill the process of sshtmp.sh and remove the script in / etc/rc.local. Then check to see if the permissions are normal.

Reference material for this article: http://blog.sina.com.cn/s/blog_5937eedc0101h719.html

Tags: Permissions system again login success files machines directories methods clean for reference only references commands done suggestions machines results scripts materials processes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB OPPO Reno Microsoft vpn