Jenkins run as non root user

In this tutorial, How do I Jenkins run as non root user in Linux? Jenkins the essential for DevOps Roles.

Jenkins run as non root user

To change the Jenkins user, Open “/etc/sysconfig/jenkins” file. Changing JENKINS_USER variable and Make sure user exists in your system.

The default, JENKINS_USER is Jenkins USER as below

[root@DevopsRoles ~]# cat /etc/sysconfig/jenkins | grep JENKINS_USER

Changing JENKINS_USER to huupv USER.

[root@DevopsRoles ~]# sed -i -e 's/JENKINS_USER\="jenkins"/JENKINS_USER\="huupv"/g' /etc/sysconfig/jenkins

The screen output terminal:

[root@DevopsRoles ~]# cat /etc/sysconfig/jenkins | grep JENKINS_USER

The changing ownership Jenkins home

[root@DevopsRoles ~]# chown -R huupv:huupv /var/lib/jenkins 
[root@DevopsRoles ~]# chown -R huupv:huupv /var/cache/jenkins
[root@DevopsRoles ~]# chown -R huupv:huupv /var/log/jenkins

The restarted Jenkins and check user has changed with ps command.

[root@DevopsRoles ~]# /etc/init.d/jenkins restart
[root@DevopsRoles ~]# ps -ef | grep jenkins

The screen output terminal:

Jenkins run as non root user


Thought the article, you can use Jenkins run as the non root user as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

5 thoughts on “Jenkins run as non root user

  1. Dear Sir,

    I followd your steps jenkins service run using non root user,’
    I am unable to stop/start jenkins services using non root user id ec2-user. But i can deploy package etc.

    Only root user allow me stop/start jenkins services. Any suggestion how to stop/start jenkins services using non root user .

    Please advise.

    [ec2-user@ip-10-0-1-12 sysconfig]$ service jenkins start

    Starting Jenkins runuser: may not be used by non-root users


  2. HI,
    need quick help on this. I am doing the same process in ubuntu and when i tried to start jenkins. below resulted:

    COMMAND: sudo service jenkins start tried with systemctl as well
    Job for jenkins.service failed because the control process exited with error code.
    See “systemctl status jenkins.service” and “journalctl -xe” for details.

    Starting LSB: Start Jenkins at boot time…
    16]: Correct java version found
    16]: * Starting Jenkins Automation Server smsadmin
    (to smsadmin) root on none
    pam_unix(su-l:session): session opened for user smsadmin by (uid=0)
    pam_unix(su-l:session): session closed for user smsadmin
    16]: …fail!
    jenkins.service: Control process exited, code=exited, status=7/NOTRUNNING
    jenkins.service: Failed with result ‘exit-code’.
    Failed to start LSB: Start Jenkins at boot time.

    Thanks in advance…

    1. Hi Rajesh,
      your system java version ?
      java -v
      I think miss java 8. Install java as command below:
      sudo apt install openjdk-8-jre
      ## Set default java version as java 8
      sudo update-alternatives –config java

    2. Hey,
      Also you have to change user and group information in /usr/lib/systemd/system/jenkins.service (for Centos)
      Have a great coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.