$JENKINS_HOME/init.groovy.d/basic-security.groovy
In Ubuntu 16 Jenkins home directory places in /var/lib/jenkins
#!groovy
import jenkins.model.*
import hudson.security.*
def instance = Jenkins.getInstance()
def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount("admin_name","admin_password")
instance.setSecurityRealm(hudsonRealm)
instance.save()
$JENKINS_HOME/init.groovy.d/basic-security.groovy
file