【作死】LINUX系统文件权限被搞坏了怎么办?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sac761/article/details/82870940

对整个linux系统进行了权限修改操作:sudo chmod -R 777 * 之后会怎样?

你怎么这么会皮呢?

系统当然被你搞残啦,很多系统文件都需要严格的读写权限限定,你这样一搞,很多程序和服务都启动不了了,比如sudo 等指令可能都用不了了,SSH和samba等软件服务都GG了。

说多了都是泪,下面是我的自我救赎:

 一,sudo等指令不能用

参考https://www.simapple.com/388.html
后出现sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner的错,那就去掉写权限吧:

chmod 4755 /usr/lib/sudo/sudoer.so

这中间可能会报其他文件的写权限的错,都用4755给它执行一下。

二,ssh用不了

把对应文件的权限改成这样:查看指令 ls -l /etc/ssh

drwxr-xr-x   2 root root   4096  9月 28 20:48 ./
drwxr-xr-x 151 root root  12288  9月 28 20:50 ../
-rw-r--r--   1 root root 242091  4月 14 20:13 moduli
-rw-r--r--   1 root root   1690  4月 14 20:13 ssh_config
-rw-r--r--   1 root root   3917  9月 28 20:49 sshd_config
-rw-------   1 root root    668  9月  9 16:55 ssh_host_dsa_key
-rw-r--r--   1 root root    618  9月  9 16:55 ssh_host_dsa_key.pub
-rw-------   1 root root    227  9月  9 16:55 ssh_host_ecdsa_key
-rw-r--r--   1 root root    190  9月  9 16:55 ssh_host_ecdsa_key.pub
-rw-------   1 root root    419  9月  9 16:55 ssh_host_ed25519_key
-rw-r--r--   1 root root    110  9月  9 16:55 ssh_host_ed25519_key.pub
-rw-------   1 root root   1675  9月  9 16:55 ssh_host_rsa_key
-rw-r--r--   1 root root    410  9月  9 16:55 ssh_host_rsa_key.pub
-rw-r--r--   1 root root    338  9月  9 16:55 ssh_import_id

-rw-r--r--权限为0644,-rw-------权限为0600

#cd /etc/ssh

#chmod 0644 *

#chmod 0600 ssh_host_ecdsa_key  ssh_host_dsa_key  ssh_host_rsa_key

操作完之后一定要再检查一下是否一一对应。

三,samba用不了

  1. 首先卸载samba
    用 :
    dpkg -l |grep samba
    dpkg -l |grep smbfs
    dpkg -l |grep smb
    查看所有samba依赖,查到的所有包统统用:
    apt-get --purge remove 软件包名称
    删除干净
  2. 安装与配置samba
    参考https://blog.csdn.net/DEV_linux/article/details/27054953

猜你喜欢

转载自blog.csdn.net/sac761/article/details/82870940
今日推荐