For a long time I had been using the sudo command on Ubuntu and other Linux versions, but my main server did not have it installed. I always had to use ‘su’ with the root password to do be able to do administrative jobs. It turns out it was really easy to fix. Simply follow these steps as root (using your actual user name in place of jsmith):
apt-get install sudo
adduser jsmith sudo
This installs the sudo package, creates a sudo user group and the /etc/sudoers configuration file. It then adds your user to the user group sudo, which per the default /etc/sudoers file is permitted to run sudo.
Note that these changes do not take effect for any ssh sessions already open. If you have a running session logged in as the user you just added to the sudoers list and you attempt to use sudo from there, it will ask for your password and then fail with this error message:
jsmith is not in the sudoers file. This incident will be reported.
The fix is simple: log out and log back in again. On the new login, the new configuration will be picked up and you will be able to use sudo as intended.
If you would like to do multiple commands from sudo like you could from su, it’s very easy. Simply use sudo to launch a copy of bash and exit after you’re done:
sudo bash