4

I am asked for sudo password frequently while entering sudo commands in the terminal, but I can't remember whether I am a sudo user or not. Similarly I don't know any superuser do password. I am confused in this password matter.

EXAMPLE:

$ sudo aplay -l
[sudo] password for deepak:

I don't know what to do in the previous password asking command. Similarly like above example, for many times I am asked for sudo password. How can I resolve it?

Deepak Ramanan
  • 41
  • 2
  • 2
  • 8

2 Answers2

8

It's just your regular password.

The password to run commands with sudo is your password, not a separate password. It is the same password that:

  • you came up with and typed in when you installed Ubuntu or created your account
  • you type in on the login screen (unless you have automatic login)
  • you type in to unlock the screen

When you're asked for your password in a terminal, it is normal that nothing is shown while you are typing it. To enter your password for the sudo command, type it in and press Enter.

  • If you enter your password correctly and you are an administrator--which on Ubuntu means a user who is allowed to perform actions as the root user through sudo and polkit--then the command will run. (Non-administrators can be permitted to run certain commands with sudo too, but this is not set up by default.)

  • If you enter your password correctly but you are not an administrator and aren't allowed to run the command as root with sudo, you'll get an error:

    username is not in the sudoers file.  This incident will be reported.

    ("Reported" just means written to a log file. Attempting to run a command with sudo on your own computer that your user account isn't set up to be allowed to run is harmless, and the scary "This incident will be reported" thing can be ignored.)

To see if you're set up to sudo to root, check if you're in the sudo group.

Another way to find out if your user account is an administrator and allowed to run commands as root with sudo is to check if it's a member of the sudo group. To list all the groups you're in, run:

groups

Users are usually in their own group (named the same as their username) and several other groups. If you're an administrator the output of groups will look something like:

username adm cdrom sudo dip plugdev lpadmin sambashare

If you're not an administrator it will look something like this (i.e., it will not contain sudo):

username adm cdrom dip plugdev lpadmin sambashare

If you only have one user account and it's been removed from the sudo group, see How do I add myself back as a sudo user? This is not a very common situation, though.

For more detailed information, you can ask sudo about your abilities.

A third way to find out if you're an administrator is to run sudo -l. You'll have to enter your password. Then:

  • Non-administrators who aren't set up to run any commands with sudo will see the message

    Sorry, user username may not run sudo on host.

    where username is your username and host is the hostname (computer name) of your Ubuntu system.

  • Administrators (i.e., members of the sudo group) will see some information ending in the lines:

    User username may run the following commands on host:
    (ALL : ALL) ALL
  • Users who are set up to run some commands as root but not all commands will see output documenting their abilities. (See man 5 sudoers for technical details.)

Further Reading

Eliah Kagan
  • 117,780
  • i really gained somethings from your guidance and i think probably you are helping me by answering my questions.i think you may be the helper for all my queries in this field ELIAH KAGAN – Deepak Ramanan May 01 '15 at 14:02
2
getent group sudo | grep your-user-name

If you find your username among the list from command above then you are a sudo.

To use a sudo with no password which is not advised at all and make you in risk to hurt your system

Open terminal window and type:

sudo visudo

In the bottom of the file, type the follow:

username ALL=(ALL) NOPASSWD: ALL
Maythux
  • 84,289