0

I want run tomcat9 with a user different from the default, and searching the web, I found out that I can configure this in the file /etc/default/tomcat. In this file, I change the lines with TOMCAT9-USER and TOMCAT9_GROUP and change to the desired user and group I wish tomcat9 was running under. After that, I stop tomcat, and start again (I've trie restart too), but when I run ps -ef, tomcat still is displayed running under user tomcat. What I am doing wrong here? Is there any other file I need modify?

Kleber Mota
  • 8,521
  • 31
  • 94
  • 188

3 Answers3

2

I find the problem. With ubuntu, apparently the file /etc/default/tomcat9 is not used; I managed to change the configuration I wanted with the command: systemctl edit --full tomcat9.service, which edits the file /etc/systemd/system/tomcat9.service.

Kleber Mota
  • 8,521
  • 31
  • 94
  • 188
0

Try using service.bat or service.sh to set the user which the tomcat process need to run as.

Try to follow the below Tomcat 9 documentation

https://tomcat.apache.org/tomcat-9.0-doc/windows-service-howto.html

Prem
  • 1
  • 2
0

[Originally this answer appeared under How do I run Tomcat 9 as a different user, which is a duplicate of this question]

The Tomcat 9 packages based on Debian 10 use SystemD to run. Therefore you need to run:

sudo systemctl edit tomcat9.service

(or create a file named /etc/systemd/system/tomcat9.service.d/override.conf) and type:

[Service]
User=your_user
Group=your_group

in the editor that appears. Check the systemd.exec manual for more options or see the vendor supplied unit file (/lib/systemd/system/tomcat9.service).

When you restart your server, it will use the new settings.

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43