The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 9,534     Votes:  3 
Tags: command-line   sudo   password  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/1195804
Title: How do I force `sudo` to ask for a password each time when a specific command is used?
ID: /2019/12/13/How-do-I-force-_sudo_-to-ask-for-a-password-each-time-when-a-specific-command-is-used_
Created: December 13, 2019    Edited:  December 13, 2019
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


You can set sudo to always ask for a password:


$ sudo cat /etc/sudoers
# 
# This file MUST be edited with the 'visudo' command as root.
# 
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
# 
# See the man page for details on how to write a sudoers file.
# 
Defaults	env_reset, timestamp_timeout=120, pwfeedback
# Defaults	mail_badpass
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

In my configuration I have sudo timeout set at 2 hours (120 minutes) before it asks for a password again. Setting it to 0 will require password every time you use sudo

⇧ How to set up night light mode on one monitor and the second one normal Gnome3: How to disable "Shutdown" button  ⇩