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_ipEnter 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 updateInstall Sudo
Install the sudo package using the apt package manager. Confirm the installation when prompted:
apt install sudoAdd 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 usernameVerify the Installation
Switch to the user account you just configured to test the setup:
su - usernameOnce 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 whoamiIf the output returns root, sudo is installed and
configured correctly.