0

I'm on Ubuntu 14.04 and I installed Apache Tomcat 7 via

sudo apt-get install tomcat7

and without editing any configuration I can start and stop the service tomcat7 successfully (localhost:8080 shows me the "It works!" page).

The installation seems to have created a user tomcat7 under which Tomcat runs. I would like to log in as that user (rather, switch to it using su tomcat7) but I don't know the password -- yet I never configured one.

What is the password for user tomcat7?

  • 1
    Why doing this. There is no reason. – Info-Screen Jan 20 '16 at 14:17
  • 1
    @DnrDevil I don't believe that's correct - the passwords are in /etc/shadow encoded/encrypted, and system users do not have passwords associated with them typically as they're not standard login accounts. – Thomas Ward Jan 20 '16 at 14:22
  • @Info-Screen, I need to set up a virtual X server for a webapp... this would be the easiest way to make sure that the display is owned by the correct user. – Gerli Jan 20 '16 at 14:27
  • @Gerli chown would work fine or just use su – Info-Screen Jan 20 '16 at 14:31
5

Firstly, there should be zero reason to login as the tomcat7 user. There's no logical use case for this, so therefore I'm not sure why you'd try and use it.

You state in your question you want to set up a virtual X server for a webapp - you don't need to login as tomcat7 to do this, though your question isn't "How can I launch a virtual X server for my web app as tomcat7 without logging in", so don't expect help here with that in this question.

Having said this, it's likely that this is a System User Account and not an actual user; these users typically have no passwords associated with it, as it is designed to be used by system daemons and services, rather than users. Therefore, you cannot login as that user as it isn't designed to be logged into by users - to use the user, you have to use su to switch user to it, and you have to do so as superuser or root or with sudo. Also note that there's the option of setting a password, but it's ill-advised to do so, for that user.


Option 1 (Recommended, and the Proper Way to do this): su as sudo or root/superuser

You will need to have sudo power, or access to the root user to get this working with these instructions.

With sudo:

sudo su tomcat7

As root user:

su tomcat7

Option 2 (NOT RECOMMENDED, because it introduces security concerns and other issues): Set a password

You will need to have sudo power, or access to the root user to get this working with these instructions, and it is VERY likely you will break things by doing this. I HIGHLY RECOMMEND not doing this!

Set a password.

With sudo:

sudo passwd tomcat7
[set a password with the prompts]

As root:

passwd tomcat7

Once the password is set, then you can just login to the user (either via SSH or the console directly).

Again, I strongly recommend that you do not do this method - this could break Tomcat7, and can actually put your system at risk because someone can now brute-force the password and have access to the tomcat instance as the tomcat user itself.


To reiterate though: there is no logical reason to need to login as the tomcat7 user. Do so at your own risk as you can affect evilness on your system if you're not careful.

|improve this answer|||||
  • the Question was how to do it whitout su – Info-Screen Jan 20 '16 at 14:18
  • @Info-Screen they can't, that's the problem. There's no way to switch to the user without su, as system user accounts USUALLY do not have passwords so you can't direct-login as them anyways. – Thomas Ward Jan 20 '16 at 14:21
  • 1
    @Info-Screen to actually state otherwise, nowhere does the user ask how to NOT need su to do this. They stated they would rather be able to su to it, if you read closely. – Thomas Ward Jan 20 '16 at 14:27
  • I didn't realise there could be accounts without passwords. That's useful information. I'll look into other ways of doing what I wanted, that's fine. /etc/shadow has the line tomcat7:*:... which I assume means it is a system user account. – Gerli Jan 20 '16 at 14:40
  • @Gerli they're called 'system' accounts, and are usually used for system daemons (such as Apache or nginx which use www-data by default, or PostgreSQL db server, which uses postgres, or MySQL which uses mysql, etc.). They don't typically have passwords because only system daemons and services tend to use them... – Thomas Ward Jan 20 '16 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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