- A+
所属分类:Linux
错误一:root用户执行systemctl命令报误
1 2 3 4 |
[root@node1 ~]# systemctl restart sshd * (pkttyagent:10364): WARNING *: Unable to register authentication agent: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PolicyKit1 was not provided by any .service files Error registering authentication agent: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PolicyKit1 was not provided by any .service files (g-dbus-error-quark, 2) |
错误二:root用户切换到普通用户报错
1 2 3 4 |
[root@node1 ~]# useradd test [root@node1 ~]# su - test su: warning: cannot change directory to /home/aihps: Permission denied su: failed to execute /bin/bash: Permission denied |
解决方法
1 2 3 4 5 6 7 8 9 |
[root@node1 ~]# stat / File: ‘/’ Size: 4096 Blocks: 8 IO Block: 4096 directory Device: fd01h/64769d Inode: 2 Links: 23 Access: (0600/drw——-) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2021-09-20 09:54:45.692000000 +0800 Modify: 2021-09-25 02:41:46.204000000 +0800 Change: 2021-09-25 02:41:46.204000000 +0800 Birth: - |
问题出来了,根目录没有X权限!
解决办法修改根目录权限。
1 |
[root@node1 ~]#chmod 755 / |
修改后,问题消失。
1 2 3 4 5 6 7 8 9 |
[root@node1 ~]# stat / File: ‘/’ Size: 4096 Blocks: 8 IO Block: 4096 directory Device: fd00h/64768d Inode: 64 Links: 18 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2021-09-30 04:27:08.309843097 +0800 Modify: 2021-09-30 04:23:57.321016467 +0800 Change: 2021-10-25 13:43:22.561332262 +0800 Birth: - |
修复后显示 Access: (0755/drwxr-xr-x) 权限正常!
产生上述问题的操作:
第一种,chmod 600 /,可以导致。 (在内核3.10.0-693.el7.x86_64的CentOS7下好像规避了root用户systemctl权限不足的问题)
第二种,chmod 700 /lib/ld-xxxx.so,也可以导致su失败。 (在内核3.10.0-693.el7.x86_64的CentOS7下无该文件)
/ 权限的丢失对于各种运行在自己用户身份上的daemon也存在同样的影响。