next342
Posts: 23
Joined: Thu Feb 07, 2013 7:13 am

sudo?

Sat Feb 09, 2013 12:33 am

im trying to log into sudo to install something but when i type in "su" into the terminal to sign in as sudo i dont know the password and it asks for one .Please help

wimble
Posts: 34
Joined: Tue Feb 05, 2013 9:52 am

Re: sudo?

Sat Feb 09, 2013 1:03 am

The root account doesn't have a password, so it's natural that you don't know it. The use of su to become root disappeared several years ago, as sudo became more prevalent (although you can still use su to become a different user on the system).

You don't "log in" to sudo, you use it to run a single command as superuser.
So:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install <whatever>

If you're logged in as the "pi" user, then it'll just do what you tell it to do. If you're logged in as a different user, then it'll still ask for a password, but this is just *your* password (to make sure it's really you trying to do something, rather than your cat, playing while you're away).

If you *really* want a session as the superuser, then:
sudo -i
and it'll ask for your password, or not, as above. But it's not recommended to do that.

Mobius
Posts: 238
Joined: Thu Aug 30, 2012 1:07 am
Location: San Angelo, Texas USA

Re: sudo?

Sat Feb 09, 2013 1:04 am

Don't worry about logging in as the super user. Your basic Pi user account should have super user privs. All you have to do before executing a command like "apt-get install xxx" is to preface it with "sudo".

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: sudo?

Sat Feb 09, 2013 1:06 am

you can type

sudo su

to jump into a root shell prompt too

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: sudo?

Sat Feb 09, 2013 1:08 am

To use "su" the root password must be set it's usually unset on a freshly installed copy of Linux.
An alternative to this would be "sudo su" which rather amusingly gives you root access without a password. :)

Richard S.

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: sudo?

Sat Feb 09, 2013 1:11 am

redhawk wrote:To use "su" the root password must be set it's usually unset on a freshly installed copy of Linux.
Richard S.
Usually unset on Debian, and Raspbian, and maybe others. However, on many Linux distributions, the root password is set, with a default, and should be changed immediately.

User avatar
rew
Posts: 425
Joined: Fri Aug 26, 2011 3:25 pm

Re: sudo?

Sat Feb 09, 2013 5:18 pm

tonyhughes wrote: However, on many Linux distributions, the root password is set, with a default, and should be changed immediately.
THAT I haven't seen in the 22 years I've been using Linux. In the past most asked for your root password during installation. Raspian is "new" in that it is often distributed as an image, instead of being installed from the packages. This is possible because the hardware is so uniform, but it has the disadvantage that you'll have a "known password" on such a system.

Someone will be bitten by this in the future. For a ten-year-old it's great fun to have a raspberry pi scan for "new" raspberry pi's on the network, immediately login as user "pi" with the known password, and then sudo to add a new account for indefinite access to that pi (or actually SD image)....
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

Return to “Beginners”