CentOS8 Tomcat – Can’t Run Command Under /bin/false User

centoscentos8sutomcat

Centos 8.

There is snowuser:

[snowuser@snowcannon-01 ~]$ cat /etc/passwd | grep snowuser  
snowuser:x:1002:1002::/home/snowuser:/bin/bash   
[snowuser@snowcannon-01 ~]$ groups  
snowuser wheel

There is tomcat user:

[snowuser@snowcannon-01 ~]$ cat /etc/passwd | grep tomcat  
tomcat:x:1003:1003::/opt/tomcat:/bin/false  


cat /etc/group | grep "tomcat\|snowuser"  
wheel:x:10:ydyachuk,amsliusar,snowuser  
snowuser:x:1002:   
tomcat:x:1003:   

Trying to run Tomcat's start script under tomcat user:

/bin/su tomcat -c /opt/tomcat/bin/startup.sh

But got nothing meaning that neither any error message appeared nor Tomcat process was executed.

Only one detail I have is that command was being executed with errors:

[snowuser@snowcannon-01 ~]$ echo $?
1

Seems tomcat user has proper permissions for the script execution:

[snowuser@snowcannon-01 ~]$ ll /opt/tomcat/bin/startup.sh 
-rwxr-xr-x. 1 tomcat tomcat 1904 Nov 11 15:14 /opt/tomcat/bin/startup.sh

How can I make Tomcat running?

Best Answer

Setting the default shell to /bin/false means that su will switch user, and then execute

/bin/false -c /opt/tomcat/bin/startup.sh

You can use the -s option to su to override the setting in /etc/passwd, but this is only permitted if the calling user is root, or the existing entry in /etc/passwd is listed in /etc/shells.