Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What will be the recommended way to ensure that a Tomcat7 instance is running as the tomcat7 (or any other) user?

I suppose that I can modify tomcat7-instance/bin/startup.sh and tomcat7-instance/bin/shutdown.sh and add 'su tomcat7' at the top.

In Tomcat6 I think it was the environment variable TOMCAT6_USER.

share|improve this question
If you are asking for the "secure way" most likely will provoke debates. Now if you ask "how to set a different user for tomcat7?" that is answerable. BTW, tomcat starts with user tomcat, as far I remember if you installed the deb package.. –  Braiam Nov 6 '13 at 0:56

1 Answer 1

up vote 3 down vote accepted

The most common way is to install the standard tomcat7 package with apt-get and to start it using:

sudo service tomcat7 start

The default user and group are configured in /etc/default/tomcat7 as you can see in this excerpt:

# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat7.

# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat7.
share|improve this answer
TOMCAT7_USER and TOMCAT7_GROUP was what I was looking for. Thanks –  Adrian Ber Nov 6 '13 at 13:19
I modified TOMCAT7_USER in tomcat7-instance/bin/setenv.sh and started the server. But if I display the process using ps the user is not the one specified in TOMCAT7_USER. –  Adrian Ber Nov 7 '13 at 1:17
Why don't you modify it directly in /etc/default/tomcat7? –  David Levesque Nov 7 '13 at 3:19
Let's say that I have two Tomcat user instances and I want to launch them as different users. –  Adrian Ber Nov 7 '13 at 9:56
That's a scenario I'm not familiar with, but in this case I don't think you can run Tomcat as a service and the above config does not apply. Maybe you should ask a separate question about that. –  David Levesque Nov 7 '13 at 15:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.