sudo

From wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Install

sudo is probably pre-installed with your system. To test it, run

$ sudo -l
Matching Defaults entries for arthur on deepthought:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, insults, env_keep+="SSH_CLIENT SSH_CONNECTION SSH_TTY", env_keep+=COLORFGBG, passwd_timeout=5

User arthur may run the following commands on deepthought:
    (ALL : ALL) ALL

In case it is not installed, you can install it using

$ su -c "apt install sudo"

Configure

Backup root Access

Some Linux distributions (Ubuntu, Raspbian…) come with sudo preconfigured and no password for the root user. This pose a risk of locking you out in case you break sudo.

If you are not confident, you can add a password to the root user before edition to be sure to have a second way to gain root access

$ sudo passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
# su
Password: 
# exit

Editing

$ sudo visudo
// or
$ su -c visudo

Remove root Password

Once you are done configuring sudo, you might decide to disable the root account (the is the default state on Ubuntu). This will leave you with sudo for all tasks requiring the root account.

$ sudo passwd -dl root