使用sudo时不再重复输入密码
首先查看一下 /etc/sudoers 的内容
vim /etc/sudoers
其中与主题相关的只有这一句:
所以:不再重复输入密码的方法就是
在这两行下面加一行:
%username ALL=(ALL) NOPASSWD:ALL
#此处username换为需要频繁使用sudo的sudo组成员的用户名
修改后结果
测试一下:
安装了一下gdb,确实没有再输入密码
[wdf@linuxprobe workspace]$ sudo yum install gdb
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository extras is listed more than once in the configuration
Last metadata expiration check: 0:02:27 ago on Thu 08 Jul 2021 09:04:25 PM CST.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================================================================
Installing:
gdb x86_64 8.2-15.el8 appstream 298 k
Installing dependencies:
gc x86_64 7.6.4-3.el8 appstream 109 k
gdb-headless x86_64 8.2-15.el8 appstream 3.7 M
guile x86_64 5:2.0.14-7.el8 appstream 3.5 M
libatomic_ops x86_64 7.6.2-3.el8 appstream 38 k
libipt x86_64 1.6.1-8.el8 appstream 50 k
libbabeltrace x86_64 1.5.4-3.el8 baseos 200 k
Transaction Summary
===================================================================================================================================================================================================================
Install 7 Packages
Total download size: 7.9 M
Installed size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): gc-7.6.4-3.el8.x86_64.rpm 57 kB/s | 109 kB 00:01
(2/7): gdb-8.2-15.el8.x86_64.rpm 121 kB/s | 298 kB 00:02
(3/7): libatomic_ops-7.6.2-3.el8.x86_64.rpm 140 kB/s | 38 kB 00:00
(4/7): libipt-1.6.1-8.el8.x86_64.rpm 20 kB/s | 50 kB 00:02
(5/7): libbabeltrace-1.5.4-3.el8.x86_64.rpm 154 kB/s | 200 kB 00:01
(6/7): guile-2.0.14-7.el8.x86_64.rpm 265 kB/s | 3.5 MB 00:13
(7/7): gdb-headless-8.2-15.el8.x86_64.rpm 189 kB/s | 3.7 MB 00:19
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 406 kB/s | 7.9 MB 00:19
warning: /var/cache/dnf/appstream-b596fa608e18089e/packages/gc-7.6.4-3.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
CentOS Linux 8 - AppStream 0.0 B/s | 0 B 00:00
Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial]
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
所用系统
[root@linuxprobe etc]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.0 (Ootpa)
ps:使用其他系统应该也有效,ubuntu20.04.1上验证过。
Thanks for you reading!
如有疑问,可以一起交流:
2728946156@qq.com