Ubuntu18.04 设置 sudo 不需要输入密码

2023-05-16

1、在系统启动后,对于有些系统设备操作,需要使用root权限执行;这时候往往需要用到sudo命令

2、使用sudo命令,必须输入用户密码,但是在应用程序里面,输入密码操作复杂;

3、直接将系统的sudo设置为无密码执行,就可以了;

4、在 /etc/下面有个sudoers 文件,使用sudo vi /etc/sudoers 打开

Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
~                                

 5、将自己用户名增加进去;

hh      ALL=(ALL) NOPASSWD: ALL

6、重新启动后,输入sudo,不再要求输入密码了。 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ubuntu18.04 设置 sudo 不需要输入密码 的相关文章

随机推荐