Linux operating system su command is invalid

Linux operating system su command is invalid

Operating environment: CentOS Linux release 7.3.1611 (Core)

Problem recovery

Use yum to install influxdb, the script automatically creates influxdb groups and users.
Try to switch from root to influxdb user but found that it is not possible:

[root@plat-ecloud01-mgmt-monitor04 ~]# su - influxdb
Last login: Tue Dec  3 14:06:01 CST 2019 on pts/2
[root@plat-ecloud01-mgmt-monitor04 ~]# whoami
root

Check whether the influxdb group exists:

[root@plat-ecloud01-mgmt-monitor04 ~]# groups influxdb
influxdb : influxdb

Check whether the influxdb user exists:

[root@plat-ecloud01-mgmt-monitor04 ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/bin/false
lp:x:4:7:lp:/var/spool/lpd:/bin/false
sync:x:5:0:sync:/sbin:/bin/false
shutdown:x:6:0:shutdown:/sbin:/bin/false
halt:x:7:0:halt:/sbin:/bin/false
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/bin/false
games:x:12:100:games:/usr/games:/bin/false
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/bin/false
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
ovirtagent:x:175:175:oVirt Guest Agent:/usr/share/ovirt-guest-agent:/sbin/nologin
systemd-bus-proxy:x:998:995:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:997:994:systemd Network Management:/:/sbin/nologin
deploy:x:1000:1000::/home/deploy:/bin/bash
ntp:x:38:38::/etc/ntp:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
nslcd:x:65:55:LDAP Client User:/:/sbin/nologin
dockerroot:x:996:993:Docker User:/var/lib/docker:/sbin/nologin
zabbix:x:995:992:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin
grafana:x:994:991:grafana user:/usr/share/grafana:/sbin/nologin
influxdb:x:993:990::/var/lib/influxdb:/bin/false

Explain that both influxdb group and user exist

problem analysis

In fact, the cause of the problem has been found in / etc / passwd just now:

[root@plat-ecloud01-mgmt-monitor04 ~]# getent passwd influxdb
influxdb:x:993:990::/var/lib/influxdb:/bin/false

There is no bash assigned to the influxdb user, so you cannot switch to this user.

problem solved

Modify this behavior in the / etc / passwd file as:

[root@plat-ecloud01-mgmt-monitor04 ~]# vim /etc/passwd

influxdb:x:993:990::/var/lib/influxdb:/bin/bash

Use su again to switch to the influxdb user:

[root@plat-ecloud01-mgmt-monitor04 ~]# su - influxdb
Last login: Tue Dec  3 14:12:53 CST 2019 on pts/2
-bash-4.2$ 

success!

Published 136 original articles · Like 58 · Visits 360,000+

Guess you like

Origin blog.csdn.net/sunbocong/article/details/103366364