使用sudo时不再重复输入密码

使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时空流亡者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值