Difference between revisions of "sudo"

From wiki
(Created page with "== Install == <code>sudo</code> is probably pre-installed with your system. To test it, run<syntaxhighlight lang="console"> $ sudo -l Matching Defaults entries for arthur on d...")
 
m (typo)
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:
 
     (ALL : ALL) ALL
 
     (ALL : ALL) ALL
 
</syntaxhighlight>In case it is not installed, you can install it using<syntaxhighlight lang="console">
 
</syntaxhighlight>In case it is not installed, you can install it using<syntaxhighlight lang="console">
$ su
+
$ su -c "apt install sudo"
Password:
 
# apt install sudo
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Configure ==
 
== Configure ==
 +
 +
=== Backup root Access ===
 +
Some Linux distributions (Ubuntu, Raspbian…) come with <code>sudo</code> preconfigured and no password for the root user. This pose a risk of locking you out in case you break <code>sudo</code>.
 +
 +
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<syntaxhighlight lang="console">
 +
$ sudo passwd
 +
Enter new UNIX password:
 +
Retype new UNIX password:
 +
passwd: password updated successfully
 +
# su
 +
Password:
 +
# exit
 +
</syntaxhighlight>
 +
 +
=== Editing ===
 
<syntaxhighlight lang="console">
 
<syntaxhighlight lang="console">
 
$ sudo visudo
 
$ sudo visudo
 +
// or
 +
$ su -c visudo
 +
</syntaxhighlight>
 +
 +
=== Remove root Password ===
 +
Once you are done configuring <code>sudo</code>, you might decide to disable the root account (the is the default state on Ubuntu). This will leave you with <code>sudo</code> for all tasks requiring the root account.<syntaxhighlight lang="console">
 +
$ sudo passwd -dl root
 
</syntaxhighlight>
 
</syntaxhighlight>
 
[[Category:Linux Server]]
 
[[Category:Linux Server]]
 
[[Category:Linux Desktop]]
 
[[Category:Linux Desktop]]

Latest revision as of 22:29, 27 February 2017

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