Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How does Linux system behave when I am not sudoer? Here is what happens if I try to use sudo:

server:/tmp>$ sudo cal
[sudo] password for user:
Sorry, try again.

Is it possible that I just don't know my password or does this mean that I am not sudoer? (On another machine system printed out that I'm no sudoer and the incident will be reported)

share|improve this question

2 Answers 2

To know whether a particular user is having sudo access or not, we can use -l and -U options together.

For example,

If the user has sudo access, it will print the level of sudo access for that particular user.

   $ sudo -l -U pradeep
     User pradeep may run the following commands on this host:
     (ALL : ALL) ALL

If the user don't have sudo access, it will print that user is not allowed to run sudo on localhost.

   $ sudo -l -U pradeep.c
     User pradeep.c is not allowed to run sudo on localhost.
share|improve this answer
    
This does not work for me. Instead of giving me information it asks me for password again: server:/home/drasto>$ sudo -l -U drasto [sudo] password for drasto: There is Red Hat distro on that server if that helps –  drasto Oct 13 '12 at 19:25

You can use the -l flag to list your privileges.

-l[l] [command]
   If no command is specified, the -l (list) option will list the allowed (and forbidden)
   commands for the invoking user (or the user specified by the -U option) on the current
   host.  If a command is specified and is permitted by sudoers, the fully-qualified path
   to the command is displayed along with any command line arguments.  If command is
   specified but not allowed, sudo will exit with a status value of 1.  If the -l option
   is specified with an l argument (i.e. -ll), or if -l is specified multiple times, a
   longer list format is used.

If you're not in the file, you should get the "not in the sudoers file" error you saw on the other machine.

share|improve this answer
    
This also does not work for me. It just asks me for password: server:/home/drasto>$ sudo -l [sudo] password for drasto: –  drasto Oct 13 '12 at 19:31
1  
Put in your password –  Kevin Oct 13 '12 at 19:31
1  
@Kevin @Michael My password does not work. I only know about one password for that server and that is the one I use to log in to the server. That one simply does not work when I'm asked for my sudo password (I have tried it about 100 times, capslock, numlock, etc). But the whole think does not make sense! I want to know if I have sudo privileges but to find it out I need sudo privileges?! To run sudo -l I need sudo password? So I have to be root to know if I'm root?! –  drasto Oct 13 '12 at 23:43
1  
@drasto As bill said, sudo is looking for your login password. So if you've tried that and it doesn't work, either sudo is horribly misconfigured or you're in a jail of some sort where it can't see or read the proper files. Either way, you have in effect no sudo permissions. –  Kevin Oct 14 '12 at 0:15
1  
@Kevin Then I'm probably in that jail of some kind. Actually I think I should not have those sudo permissions on that machine. So I was surprised when it asked me for my sudo password at the first place. Anyway it is just as I wrote: my login password does not work. –  drasto Oct 14 '12 at 6:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.