Answer by Alex for Sudo - is there a command to check if I have sudo and/or...
Very old question but I have a solution that does not require the -s flag, and does not require temperamental string operations.A good solution might be to exploit the fact that an unauthenticated sudo...
View ArticleAnswer by Harold Fischer for Sudo - is there a command to check if I have...
This is probably extreme overkill by most people's standard, but here is the (posixly correct) function I use to check if sudo is unlocked (the function will not waste its time if the user running it...
View ArticleAnswer by fxlv for Sudo - is there a command to check if I have sudo and/or...
At least on sudo 1.8.21p2, this approach works fine:if sudo -vn 2> /dev/null; then echo "You have an active sudo session"fi
View ArticleAnswer by Uwe Geuder for Sudo - is there a command to check if I have sudo...
To simplify the answer given by @wags007 if sudo -n truethen sudo idelse echo "sorry, but did not want to bother you"fiHowever, if in your https://www.sudo.ws/man/1.8.15/sudoers.man.html configuration...
View ArticleAnswer by Marco M. von Hagen for Sudo - is there a command to check if I have...
WarningAcording to Bugzilla sudo Bug ID=590 the call to sudo -n true 2&>/dev/null ; echo $? will become buggy around sudo -V 1.7.10Read Bugzilla...
View ArticleAnswer by danday74 for Sudo - is there a command to check if I have sudo...
simple answer ...sudo echoisSudo=$?if [[ "$isSudo" -ne 0 ]]; then echo "This script must be run by root or a sudo'er" echo exit 1fi# do stuffexit 0
View ArticleAnswer by Aquarius Power for Sudo - is there a command to check if I have...
The command below will show a colored indication that you have sudo granted, so you remember to do a sudo -k before going away from the machine. It is useful also on non colored terminals.As we can...
View ArticleAnswer by wags007 for Sudo - is there a command to check if I have sudo...
I know this is a really old question but here is I did in a script today. Assuming that being sudo means being able to run any command as sudo (or, at least, uptime)CAN_I_RUN_SUDO=$(sudo -n uptime...
View ArticleAnswer by Dysaster for Sudo - is there a command to check if I have sudo...
According to the sudo manual, the sudo session is determined according to the time stamp file (/usr/lib/sudo/<username>), so you may be able to figure out how much time is left by checking the...
View ArticleAnswer by JustXanny for Sudo - is there a command to check if I have sudo...
The -n option is available in newer versions of sudo, but as you stated that's not an option. There's no real way to do what you're looking for short of just trying sudo and seeing if it comes back...
View ArticleAnswer by Andreas Rehm for Sudo - is there a command to check if I have sudo...
How about the man pageman sudoList your available commands:sudo -lsudo itself has no time or date limits... see:man sudoman sudoers
View ArticleSudo - is there a command to check if I have sudo and/or how much time is left?
(Originally posted on Stack Overflow). They suggested I try here instead. Here's the original post:Sudo - is there a command to check if I have sudo and/or how much time is left?See title. I want a...
View Article