aebian

Who am I?

Musician, Programmer, Linux Geek and what not.  more...


The Categories



Stuff

Arma CodeList
GitHub Projects
Media (Gallery)
Privacy Policy
My Hardware
My Wishlist


November 21st at 9:41am
Report a website issue
For best viewing experience use a 4k screen.

nethavn Logo

❬ Back to Blog


Require password for specific commands with sudo


How you can enable passwords in sudo for specific commands only everytime will be explained here

Hi guys,

Every site or blogs tells you how to completely remove the password prompt for sudo commands.
I didn't came across a site that tells anything else.

This post will show, how you can prompt for passwords everytime for specific commands only.
This can be useful for passwording commands like rm, shutdown or similiar ones that could accidentally produce a worst case.


Requirements:

  • sudo installed
  • sudo access
  • a noVNC console or an active root user with valid password in case something goes wrong.

First of create a file called default in /etc/sudoers.d/ Then edit the file and add the following code into:

The variable Cmd_Alias will store the commands you want passworded. You need to enter the full path of each.
You can add as many commands as you like. Seperate them with a comma and you're good to go.

If thats done, you can use any other sudo command without a password and the added commands in the file will ask you for a password.