In Redhat linux. from my user if I issue command sudo su -> changes to root su tomcat --> changes to tomcat user
Why does tailing the commands in single line doesn't work? sudo su; su tomcat --> stil in root. Doesn't switch to tomcat
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
sudo su; su tomcat
are two commands. The shell will run the first and when it completes it will run the second. Note that the shell does not pass the second command as an argument to the first command.
When you exit the first command it will run the second
sudo su ; su tomcat [sudo] password for iain: root@host:iain]$ exit exit Password: <---- this is the prompt from the second su command.
You can use sudo to transition to the tomcat user directly
sudo -u tomcat <some command>
-s to get a shell e.g.
whoami iain sudo -s -u tomcat whoami tomcat