Skip to content
Advertisement

How to execute a command on behalf of a user if login is denied

I need to run tomcat on behalf of tomcat user. But in /etc/passwd I have the following line:

tomcat:x:505:506::/usr/share/tomcat:/bin/nologin

So when I try to do this: sudo su tomcat ./bin/startup.sh

It complains about: su: /bin/nologin: No such file or directory

How do I execute the command with proper permissions?

Thanks in advance!

P.S. I’m trying to reverse engineer the configuration and it’s production. So I have to be delicate…

Advertisement

Answer

Try running:

sudo -u tomcat ./bin/startup.sh

By avoiding su you avoid trying to invoke the user’s login shell.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement