sajis997
Posts: 1
Joined: Tue Nov 01, 2016 3:03 pm

password is not set

Tue Nov 01, 2016 3:08 pm

Hi

I have the raspberry pi3 model 3 version 1.2 and I am trying to reset the password both by

Code: Select all

sudo passwd
and

Code: Select all

sudo raspi-config
. But everytime I am typing sudo and comand , for example apt-get install ... it is not prompting me for password.

Is there something I am doing wrong ?


Thanks

User avatar
topguy
Posts: 7313
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: password is not set

Tue Nov 01, 2016 7:21 pm

Edit:
"sudo passwd" will set password for "root" user and not "pi" user. Are this what you want ?

--

The password are cached for some time so if you run two sudo commands with only a few seconds between it will not ask again.

Also if the file "/etc/sudoers" contain "pi ALL=(ALL) NOPASSWD:ALL" then the user pi will never be asked for password.
If you want to test the password do "ssh pi@localhost", ssh will always ask fro password.
Last edited by topguy on Tue Nov 01, 2016 7:25 pm, edited 1 time in total.

User avatar
ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6460
Joined: Fri Jul 29, 2011 5:36 pm

Re: password is not set

Tue Nov 01, 2016 7:24 pm

topguy wrote:Also if the file "/etc/sudoers" contain "pi ALL=(ALL) NOPASSWD:ALL"
Quick note that in recent versions that line has moved to /etc/sudoers.d/010_pi-nopasswd.

klricks
Posts: 8861
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA

Re: password is not set

Tue Nov 01, 2016 7:35 pm

sajis997 wrote:...... But everytime I am typing sudo and comand , for example apt-get install ... it is not prompting me for password.

Is there something I am doing wrong ?
No this behavior is normal for the Raspbian OS.
The pi user default password is: raspberry
Using sudo will give user pi full control as root.

The root password is not set by default but is not needed because the pi user can use sudo to do most everything.
3B+ & 4B4G Running RPi OS Bookworm w/ Desktop

dgordon42
Posts: 807
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: password is not set

Tue Nov 01, 2016 7:57 pm

It's not clear from your post what you are trying to do, or what you have done.

First, the two commands you quoted do two entirely different things on the Pi.
"sudo passwd" will set or change the password for user root
"sudo raspi-config" will change the password for user pi

By default, Raspbian does not set a password for user root, therefor a user cannot log in as root. This is a security feature.
If you then run "sudo passwd", you will be prompted to set a password for root. Once you have done this, you may log in as user root with the password you have just set.

"sudo raspi-config" allows you to set the default password for user pi from "raspberry" to one of your own choosing. This is a very good idea, it prevents anybody else from logging into your Pi. You can do the same thing in the terminal with the "passwd" command, note that 'sudo' is not used here.

By default on Raspbian, the user pi has sudo privileges. Also by default on Raspbian, the user pi is not required to enter pi's password when using sudo. This is different from some other Linux distros, and is why you are not being asked for a password when using 'sudo'.
You can change this behavior by editing the file '/etc/sudoers.d/010_pi-nopasswd. Open the file and change the word "nopasswd" to "passwd". It is not necessary to change the name of the file (as far as I know).

On versions of Raspbian dated before about the 20th of Oct, 2016, the file '/etc/sudoers.d/010_pi-nopasswd' will not exist!
If this is the case, it will be necessary to edit the 'sudoers' file. You do this with the "sudo visudoers" command. This will open the file in the default text editor, but more importantly will prevent you from saving the edited file with a syntax error in it. An incorrect sudoers file can prevent your Pi from booting.
In the sudoers file, find the line "pi ALL=(ALL) NOPASSWD: ALL", and change 'NOPASSWD' to 'PASSWD'. Leave the rest of the file as is.

I recommend that you do change the user pi's password from the default, as explained above.
I recommend that you do not set a root password or change the sudo settings unless you have some experience of Linux administration and have a good reason to do so. Changing theses settings can make your Pi unbootable and cause loss of data. Just log in as pi, or set up another normal user account if you wish, and use 'sudo' when you need to run a command or program as root.

Hope this helps,
Dave.

Return to “Beginners”