创建一个/sbin/nologin用户
[root@host101 ~]# useradd -s /sbin/nologin redis [root@host101 ~]# grep redis /etc/passwd redis:x:501:501::/home/redis:/sbin/nologin [root@host101 ~]# su redis -c "echo ss" This account is currently not available.
1.su运行
[root@host101 ~]# su redis -s /bin/bash -c "echo ss" ss
2.sudo运行
[root@host101 ~]# sudo -u redis echo ss ss