Steps to Setup Nexus Repository Manager on Ubuntu 20.04 LTS

Nexus is a free & open source repository manager. It helps to collect & manage the dependencies so that we are not constantly juggling a collection of JARs. It provides a simple way to create & distribute software. It is used to collect, retrieve, manage our artifacts. Artifacts is a place where we can store  all artifacts which are needed for the projects.

There are some steps to setup Nexus repository manager on ubuntu:


  • Open JDK 8
  • Minimum CPU’s: 4
  • ubuntu server with sudo privileges.
  • Firewall/Inbound port: 22, 8081

Step 1: Update the System.

apt-get update

Step 2: Install java.

apt install openjdk-8-jdk

  • Check Java version.

java -version

  • Here is the command output.

root@ip-172-31-19-239:/home/ubuntu# java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

Step 3: To create a system account for Nexus.

useradd -M -d /opt/nexus -s /bin/bash -r nexus

  • Provide the sudo permission to Nexus user.

echo "nexus ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nexus

Step 4: Download the Nexus.

  • Change the directory.

cd /opt

  • Run the following command to download the nexus.


  • Here is the command output.

root@ip-172-31-19-239:/home/ubuntu# cd /opt
root@ip-172-31-19-239:/opt# wget
--2021-12-08 06:36:09--
Resolving (,
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
--2021-12-08 06:36:10--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 211451295 (202M) [application/x-gzip]
Saving to: ‘latest-unix.tar.gz’
latest-unix.tar.gz 100%[=============================================================>] 201.66M 91.2MB/s in 2.2s
2021-12-08 06:36:12 (91.2 MB/s) - ‘latest-unix.tar.gz’ saved [211451295/211451295]

  • Extract the downloaded folder.

tar -zxvf latest-unix.tar.gz

  • Here is the command output.

root@ip-172-31-19-239:/opt# tar -zxvf latest-unix.tar.gz

  • To rename the extracted Nexus setup folder to nexus.

mv /opt/nexus-3.37.0-01 /opt/nexus

  • Provide the following permission to Nexus & sonatype-work folder.

chown -R nexus:nexus /opt/nexus
chown -R nexus:nexus /opt/sonatype-work

  • Run nexus as service at boot time.

vim /opt/nexus/bin/nexus.rc

  • Uncomment & edit the following line.


  • To change the nexus JVM heap size.
  • Open the file.

vim /opt/nexus/bin/nexus.vmoptions

  • Edit the following lines:


Step 5: To run nexus as service using Systemd.

vim /etc/systemd/system/nexus.service

  • Add the following lines:

Description=nexus service
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop

  • To start & enable nexus servic.

systemctl start nexus
systemctl enable nexus

  • Check nexus service status.

systemctl status nexus

  • Here is the command output.

root@ip-172-31-19-239:/opt# systemctl start nexus
root@ip-172-31-19-239:/opt# systemctl enable nexus
Created symlink /etc/systemd/system/ → /etc/systemd/system/nexus.service.
root@ip-172-31-19-239:/opt# systemctl status nexus
● nexus.service - nexus service
Loaded: loaded (/etc/systemd/system/nexus.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-12-08 06:40:24 UTC; 8s ago
Main PID: 17464 (java)
Tasks: 41 (limit: 4700)
Memory: 568.3M
CGroup: /system.slice/nexus.service
└─17464 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server

  • To check nexus logs.

tail -f /opt/sonatype-work/nexus3/log/nexus.log

  • Here is the command output.

root@ip-172-31-19-239:/opt# tail -f /opt/sonatype-work/nexus3/log/nexus.log
2021-12-08 06:40:34,795+0000 INFO [jetty-main-1] *SYSTEM - ACTIVATED []
2021-12-08 06:40:34,795+0000 INFO [jetty-main-1] *SYSTEM - ACTIVATING []
2021-12-08 06:40:34,846+0000 INFO [jetty-main-1] *SYSTEM - ACTIVATED []
2021-12-08 06:40:34,846+0000 INFO [jetty-main-1] *SYSTEM - ACTIVATING []
2021-12-08 06:40:34,857+0000 INFO [jetty-main-1] *SYSTEM - ACTIVATED []
2021-12-08 06:40:34,858+0000 INFO [jetty-main-1] *SYSTEM - Running lifecycle phases [KERNEL, STORAGE, RESTORE, UPGRADE, SCHEMAS, EVENTS, SECURITY, SERVICES, CAPABILITIES, TASKS]
2021-12-08 06:40:34,859+0000 INFO [jetty-main-1] *SYSTEM - Start KERNEL
2021-12-08 06:40:34,861+0000 INFO [jetty-main-1] *SYSTEM - File: /opt/sonatype-work/nexus3/etc/logback/logback-overrides.xml

  • To open the 8081 port number in UFW firewall.

ufw allow 8081/tcp

  • Here is the command output.

root@ip-172-31-19-239:/opt# ufw allow 8081/tcp
Rules updated
Rules updated (v6)

Step 6: Open Nexus Repository Web Interface.


  • Here is the command output.

  • To click on Sign in option.

  • Default username is : admin
  • Run the below command for finding the default password.

cat sonatype-work/nexus3/admin.password

  • Here is the command output.

root@ip-172-31-19-239:/opt# cat sonatype-work/nexus3/admin.password

  • Click on Next.

  • To change the default password.
  • Click Next.

  • To configure Anonymous Access.

  • Click on Finish.

  • Finally,Log into Nexus Repository Manager.

Leave a Reply