Commands.page Logo

How to Install Sudo on Ubuntu Minimal Server

Minimal Ubuntu server installations often omit the sudo package to reduce footprint and enhance security by requiring direct root access. This article provides a step-by-step guide on how to install sudo on a minimal Ubuntu server, configure user permissions, and verify the installation to ensure secure administrative access without logging in as root.

Log in as Root

Since sudo is not yet installed, you must log in to your server using the root account. If you are using SSH, connect using the root username:

ssh root@your_server_ip

Enter the root password when prompted to gain access to the command line.

Update Package Lists

Before installing new software, ensure your package repository information is current. Run the following command:

apt update

Install Sudo

Install the sudo package using the apt package manager. Confirm the installation when prompted:

apt install sudo

Add User to Sudo Group

To allow a standard user to execute commands with administrative privileges, add them to the sudo group. Replace username with your actual non-root username:

usermod -aG sudo username

Verify the Installation

Switch to the user account you just configured to test the setup:

su - username

Once logged in as the standard user, verify sudo access by running a command that requires privileges. You will be prompted to enter the user’s password:

sudo whoami

If the output returns root, sudo is installed and configured correctly.