Bash script to check whether or not the current user can sudo without entering a password.
bash cansudo.sh
Run the command above with users that have different settings in
/etc/sudoers
!
Argument | Required | Accepts Value | Description |
---|---|---|---|
--version | No | None | Returns script name and version |
-v | No | None | Returns script name and version |
Code | Type | Description |
---|---|---|
0 | SUCCESS | The user is in sudo group and can use sudo without password |
1 | FAIL | The user can not use sudo at all because he is not in sudo group |
2 | FAIL | The user can use sudo but requires to input a password |
- Currently only tested with bash on Ubuntu 20.04
- Script may not work with zsh on Mac or other shells/OS
- You may have to adjust the
timeout
value on busy systems (seeESSENTIALS
section in cansudo.sh) - Still a bit hacky solution - use at your own risk
Resources i found during research wich helped develop this script:
- Sudo guide on jumpcloud.com
- How to timeout a sudo password prompt
- Examples how to hide the output of a backgroud process
I am not associated in any form with the mentioned resources.