Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As root I would like to login as a service user (jenkins - the CI server) and manipulate files with its user,group and umask settings.

Normally I would (as root) do sudo -i -u jenkins, or even su - jenkins. However jenkins' default shell is /bin/false, which exits immediately.

Is there a way to login as Jenkins but specify a different shell to use? Do I really have to change jenkins' shell in /etc/passwd/?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

su on linux supports setting the shell with the --shell option

su jenkins --shell=/bin/bash

You will need to su as root for this to work. From the man page:

       If the target user has a restricted shell (i.e. the shell field of
       this users entry in /etc/passwd is not listed in /etc/shell), then
       the --shell option or the $SHELL environment variable wont be taken
       into account, unless su is called by root.
share|improve this answer

Have you read the manual page (or --help output) to the su command?

su -s /bin/bash -
share|improve this answer

How about:
su - jenkins -c /bin/bash

or

sudo -u jenkins /bin/bash

share|improve this answer

Your Answer

 
discard

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.