You must create a file in
/etc/sudoers.d/
The file you created in the /etc/sudoers.d/ directory can have any name.
It is recommended to use a name that is easy to identify, such as:
- 99-axel
- axel-user
- sudo-config-axel
Rule for sweat to last forever
Defaults:username timestamp_timeout=-1
What this rule does:
- Defaults:username: Apply this setting only to the username user.
- timestamp_timeout=-1: Set the sudo password timeout to unlimited. This means that once you enter your password, you won’t be prompted again during that session.
rule not to ask for a password
username ALL=(ALL) NOPASSWD: ALL
What this rule does:
- username ALL=(ALL): Allows the user username to run any command as any user.
- NOPASSWD: ALL: Tells sudo to never prompt for a password to run commands.
Recommendation: Best practice is to use the default timeout of 15 minutes. If you need more, you can increase it to 60 minutes with timestamp_timeout=60, but making it unlimited is not recommended.
Making the wait time unlimited, or worse, not asking for a password, is a huge security risk.
a configuration file in /etc/sudoers.d/username with the content Defaults:username timestamp_timeout=60
Increase the sudo password timeout for the username user to 60 minutes.
Normally, after entering your password using sudo, you won’t be prompted again for 15 minutes. With this setting, that time is extended to one hour, allowing you to run multiple commands with sudo without having to re-enter your password.
Defaults:username: This section specifies that the rule only applies to the username. If this section doesn’t exist, the rule would apply to all users on the system.
timestamp_timeout=60: This is the directive that sets the timeout. The number 60 is the value in minutes. You can change it to any integer to adjust the time.
There’s no need to reload anything. The changes you made are already active.
Sudo is different from other services like systemd-networkd. It doesn’t run as a background daemon. Instead, the sudo command reads its configuration files (/etc/sudoers and all files in /etc/sudoers.d/) every time you run it.
This means that any changes you save to the /etc/sudoers.d/axel file will take effect on the next sudo command you run.