Home > System Tutorial > LINUX > body text

No password required to run sudo commands in Linux

WBOY
Release: 2024-01-12 08:45:34
forward
645 people have browsed it

Assuming you are running a Linux system on a computer that you only use, such as a laptop, you will need to enter a password every time you call sudo, which will be tedious in the long run. Therefore, in this guide, we will describe how to configure the sudo command to run without entering a password.

在 Linux 中运行 sudo 命令不需要密码

This setting is done in the /etc/sudoers file, which is the default security policy using the sudo command; in the user permissions specification section.

IMPORTANT: In sudeors files, the authenticate parameter is turned on by default for authentication purposes. If it is set, the user must authenticate with a password (or other authentication method) before they can run a command using sudo.

However, this default can be overridden using the NOPASSWD (no password required when user calls sudo command) flag.

The syntax for configuring user permissions is as follows:
user_list host_list=effective_user_list tag_list command_list
Copy after login

in:

  1. user_list - User list or user alias that has been set.
  2. host_list - A list of hosts or host aliases on which the user can run sudo.
  3. effective_user_list - List of users running as this user or alias
  4. tag_list - tag list, such as NOPASSWD.
  5. command_list - A list of commands or command aliases that the user runs using sudo.

To allow a user (aaronkilik in the example below) to run all commands using sudo without entering a password, open the sudoers file:

$ sudo visudo
Copy after login
Add the following lines:
aaronkilik ALL=(ALL) NOPASSWD: ALL
Copy after login

For groups, use the % characters before the group name; this means that all members of the sys group can use sudo without a password.

%sys ALL=(ALL) NOPASSWD: ALL
Copy after login

To allow users to run the specified command without a password using sudo (/bin/kill), add the following line:

aaronkilik ALL=(ALL) NOPASSWD: /bin/kill
Copy after login

下面的行会让 sys 组成员在使用 sudo 运行命令:/bin/kill/bin/rm 时不用输入密码:

%sys ALL=(ALL) NOPASSWD: /bin/kill, /bin/rm
Copy after login

在 Linux 中运行 sudo 命令不需要密码

不用密码运行 sudo

在本篇中,我们讨论了如何配置 sudo 命令来不用输入密码运行。不要忘记在评论栏中给我们提供你关于这份指导的想法和其他对于 Linux 系统管理员有用的 sudoers 配置。


The above is the detailed content of No password required to run sudo commands in Linux. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template