prodata
Posts: 163
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

A real AB question: How do I 'run as root'

Tue May 15, 2012 3:22 pm

Using the standard Debian install is 'run as root' as simple as prefixing the CLI command with sudo? Or is there more to it than that - perhaps akin to the difference in Windows between running as Administrator and using an account with administrator rights?

I'm trying to install a program which has instructions for the install to 'run as root' but just doing 'sudo make install' (for a Python program) doesn't seem to be doing the trick.

And as a related follow-up, is there a way in the LXDE File Manager of seeing the whole file system - the default seems just to show my chunk of it.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 3:46 pm

yes, in debian there is no longer a root account... basically. They decided that a full on root account was a security hole. Ergo they removed it and instead whenever you need to run something with elevated privileges you put sudo in front of it. That said, if you're going to be doing a lot of sudo commands, I usually type in sudo bash which will make that session a root session. You can also launch lxde like that and it will be like logging in as root.
Dear forum: Play nice ;-)

kasperl
Posts: 90
Joined: Fri Jan 06, 2012 6:20 pm

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 5:25 pm

abishur wrote:yes, in debian there is no longer a root account... basically.
Since when? Lenny/squeeze still have su and sudo will generate an error if the user isn't in /etc/sudoers. Did wheezy change this?

Typing su should ask for a root password, which should be provided in the documentation. You can change this by typing passwd once your are root. If you want to use sudo, there should be manuals on how to add sudo rights using the command visudo (man visudo in a terminal, or use Google for a tutorial somewhere).

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 6:24 pm

and if you don't have permission to run su, I use the "sudo su - " combo to get a root session
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 7:09 pm

kasperl wrote:
abishur wrote:yes, in debian there is no longer a root account... basically.
Since when? Lenny/squeeze still have su and sudo will generate an error if the user isn't in /etc/sudoers. Did wheezy change this?

Typing su should ask for a root password, which should be provided in the documentation. You can change this by typing passwd once your are root. If you want to use sudo, there should be manuals on how to add sudo rights using the command visudo (man visudo in a terminal, or use Google for a tutorial somewhere).
That's root permissions, it's somewhat different from a root account. The rest of my post does go on to explain the sudo thing, but as for the ability to log in *as* root. Well sure you can reactivate that, but by default it's not possible to log in as root (which was answering his question about running as Administrator vs logging in as the administrator)
Dear forum: Play nice ;-)

kasperl
Posts: 90
Joined: Fri Jan 06, 2012 6:20 pm

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 7:16 pm

abishur wrote:
kasperl wrote:
abishur wrote:yes, in debian there is no longer a root account... basically.
Since when? Lenny/squeeze still have su and sudo will generate an error if the user isn't in /etc/sudoers. Did wheezy change this?

Typing su should ask for a root password, which should be provided in the documentation. You can change this by typing passwd once your are root. If you want to use sudo, there should be manuals on how to add sudo rights using the command visudo (man visudo in a terminal, or use Google for a tutorial somewhere).
That's root permissions, it's somewhat different from a root account. The rest of my post does go on to explain the sudo thing, but as for the ability to log in *as* root. Well sure you can reactivate that, but by default it's not possible to log in as root (which was answering his question about running as Administrator vs logging in as the administrator)
Let me rephrase. Since when is the root account in Debian disabled? Every Debian install I've done (squeeze being the latest) has asked for a root password and uses a root account, without having any user in /etc/sudoers. I'm not sure about the Pi-specific distro, but this would be a pretty major change and break a lot of tutorials, so I'm quite interested in when/where/how it happened.

User avatar
grumpyoldgit
Posts: 1452
Joined: Thu Jan 05, 2012 12:20 pm

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 7:21 pm

A root account is not a requirement of setting up a Debian system. It is just an option during setup.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 7:28 pm

kasperl wrote:
abishur wrote:
kasperl wrote:
Since when? Lenny/squeeze still have su and sudo will generate an error if the user isn't in /etc/sudoers. Did wheezy change this?

Typing su should ask for a root password, which should be provided in the documentation. You can change this by typing passwd once your are root. If you want to use sudo, there should be manuals on how to add sudo rights using the command visudo (man visudo in a terminal, or use Google for a tutorial somewhere).
That's root permissions, it's somewhat different from a root account. The rest of my post does go on to explain the sudo thing, but as for the ability to log in *as* root. Well sure you can reactivate that, but by default it's not possible to log in as root (which was answering his question about running as Administrator vs logging in as the administrator)
Let me rephrase. Since when is the root account in Debian disabled? Every Debian install I've done (squeeze being the latest) has asked for a root password and uses a root account, without having any user in /etc/sudoers. I'm not sure about the Pi-specific distro, but this would be a pretty major change and break a lot of tutorials, so I'm quite interested in when/where/how it happened.
Maybe I'm wrong on this then. I'm an Ubuntu user (debian based) so I chose debian when I put it on the pi. As such I didn't have to install debian and am making an assumption that they are similar on this point. In Ubuntu you set up a default user account as opposed to a root account. Or maybe I'm misunderstanding the situation. Is it that root accounts do not use root privileges by default any more? That you make a root account and then have to explicitly state when you want to use root privileges? If I'm wrong I certainly don't want to keep giving incorrect information!
Dear forum: Play nice ;-)

kasperl
Posts: 90
Joined: Fri Jan 06, 2012 6:20 pm

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 7:39 pm

Debian has always used a minimum of two accounts, a root account and a user account, each with a password. The user account is a normal user who cannot sudo, and cannot do anything a user shouldn't do. Root is reached via su. Sudo can be enabled in Debian via visudo, executed as root, but it's not enabled by default. If the normal user is added in /etc/sudoers via visudo, you can sudo like in Ubuntu.

Ubuntu for some reason chose a sudo system where two accounts is created, but only the user account has a password. The root account can only be reached via sudo bash or suchlike. If you do passwd as root in Ubuntu you can set a root password, and afterwards su like in Debian.

Note, I'm a Debian user, and haven't used Ubuntu in a while, so I'm not too sure on the Ubuntu side of things. And I haven't touched the pi-specific distros at all, my hardware is too slow for emulation.

User avatar
croston
Posts: 706
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 10:19 pm

kasperl wrote:Debian has always used a minimum of two accounts, a root account and a user account, each with a password. The user account is a normal user who cannot sudo, and cannot do anything a user shouldn't do. Root is reached via su. Sudo can be enabled in Debian via visudo, executed as root, but it's not enabled by default. If the normal user is added in /etc/sudoers via visudo, you can sudo like in Ubuntu.

Ubuntu for some reason chose a sudo system where two accounts is created, but only the user account has a password. The root account can only be reached via sudo bash or suchlike. If you do passwd as root in Ubuntu you can set a root password, and afterwards su like in Debian.

Note, I'm a Debian user, and haven't used Ubuntu in a while, so I'm not too sure on the Ubuntu side of things. And I haven't touched the pi-specific distros at all, my hardware is too slow for emulation.
+1

I have used Debian for about 10 years at home and work and the quote above is 100% accurate for vanilla Debian installations. The RPi image is not typical in this regard and has been customised to use sudo instead of root. Look at /home/pi/.bash_history for evidence. I personally prefer it this way as well - it is what I have set up on every machine at home and work.

User avatar
jojopi
Posts: 3193
Joined: Tue Oct 11, 2011 8:38 pm

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 10:36 pm

croston wrote:
kasperl wrote:Debian has always used a minimum of two accounts, a root account and a user account, each with a password.
I have used Debian for about 10 years at home and work and the quote above is 100% accurate for vanilla Debian installations.
The installer disagrees. As grumpy said, the root password is optional. Read paragraph three.
debian-root-pass.png
debian-root-pass.png (9 KiB) Viewed 5968 times

User avatar
croston
Posts: 706
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: A real AB question: How do I 'run as root'

Tue May 15, 2012 11:07 pm

@jojopi - I stand corrected! I have not done a fresh Debian install since before squeeze so they have changed it! There is definitely an issue with being prompted for the root password in X though (in the Pi image anyway).

kasperl
Posts: 90
Joined: Fri Jan 06, 2012 6:20 pm

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 5:55 am

Ah, that's why I was asking when things changed, I rarely properly read the install instructions these days after so many installs. Thanks for the information, and sorry for any confusion that may have been caused.

User avatar
meltwater
Posts: 1015
Joined: Tue Oct 18, 2011 11:38 am

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 7:51 am

Ok...glad it wasn't just me getting confused about this!
I'd used Ubuntu and a few other live distros in the past, but nothing too in-depth.

For me, this became a problem for running programs like Gparted and Synaptic on the RPi, as they prompt "Enter the administrative password". Now the "pi" user password, "raspberry" fails here, because there is (apparently) no admin password at all, so I was wondering what you should do instead.

Now is the answer here is to log out of LXDE and back in using "sudo startx"?

I initially attempted to create a password for root, and I set it to "raspberry" (probably not the best option but still), this then messed up the "pi" user login...so I now know that isn't the solution (what is the issue with that BTW?).

Anyway, my question is, what is the best/simplest option here? Is logging out and back in the right way to be doing this (for the point of view of a beginner) or am I missing something?

Thanks.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

kasperl
Posts: 90
Joined: Fri Jan 06, 2012 6:20 pm

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 7:59 am

meltwater wrote:Ok...glad it wasn't just me getting confused about this!
I'd used Ubuntu and a few other live distros in the past, but nothing too in-depth.

For me, this became a problem for running programs like Gparted and Synaptic on the RPi, as they prompt "Enter the administrative password". Now the "pi" user password, "raspberry" fails here, because there is (apparently) no admin password at all, so I was wondering what you should do instead.

Now is the answer here is to log out of LXDE and back in using "sudo startx"?

I initially attempted to create a password for root, and I set it to "raspberry" (probably not the best option but still), this then messed up the "pi" user login...so I now know that isn't the solution (what is the issue with that BTW?).

Anyway, my question is, what is the best/simplest option here? Is logging out and back in the right way to be doing this (for the point of view of a beginner) or am I missing something?

Thanks.
I'm not sure on the best way of doing things, but running a full GUI session as root probably isn't. You can set a root password by doing "sudo passwd", and this should not mess anything up on the user account.

Actually, I'm quite interested in the 'right' way of running GUI applications as root. You can try starting LXDE, starting a terminal and doing sudo gparted, but this might throw X warnings.

In the past I've done "ssh -X roo[email protected]" followed by the right commands, but that only works with a root account and without sudo.

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 8:46 am

meltwater wrote: For me, this became a problem for running programs like Gparted and Synaptic on the RPi, as they prompt "Enter the administrative password". Now the "pi" user password, "raspberry" fails here, because there is (apparently) no admin password at all, so I was wondering what you should do instead.
This is a known problem, and a temporary fix is shown in the wiki.
http://elinux.org/R-Pi_Troubleshooting# ... y_password

Is it ironic that I am telling meltwater to read the wiki?

User avatar
meltwater
Posts: 1015
Joined: Tue Oct 18, 2011 11:38 am

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 9:02 am

Is there a wiki??? :oops:

In my defence I was just assuming I was doing it wrong.
Yes, this does fix the problem (I thought it was by design). May need a little more info to explain where this occurs (I am happy to add the info myself, but as you may have gathered, this is not a strong area for me).

Guess what my next question is...what does that command do?
It appears to be changing the /apps/gksu/sudo-mode setting, is this just disabling the sudo check, for all programs or just ones which request it (I noticed it still pops up to at least tell you it has started with sudo permissions)?

Anyway, thanks for your help, great to know the solution (I assume when the distro gets this fixed you'd just use your user password and it would be accepted).

I think in general, each distro should have a direct link to their current issues/workarounds for each release, linked directly on the distro download page (can be their own page or one in the wiki). That would at least allow beginners to try to work out what is a valid fault in the specific distro and what the solution is, or if they have just done something wrong.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 10:33 am

The fix tells the display manager to use sudo instead of su.
sudo requires the user password, su requires the (non-existent) root password.

nerak99
Posts: 9
Joined: Fri Apr 20, 2012 2:37 pm

Re: A real AB question: How do I 'run as root'

Wed May 16, 2012 1:44 pm

Although you may set a root passwd by issuing

sudo passwd root

Set the password and then use su - to set yourself as the root user

If you get around the problems associated with logging in and using your gui as root and then go on a browser, any browser based code can now run as root. Not a good idea but its your OS so go ahead if you want. Good luck.

The question "why would you do that" is reasonable in this context.

Debian having sudo as a default admin command is a good way of preventing serious accidental slip ups as it is easy to forget you are typing commands as root.
Solaris systems only allow su - from the local console by default and no log in as root to the gui is allowed by default either.

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: A real AB question: How do I 'run as root'

Thu May 17, 2012 8:27 am

I think what nerak99 is trying to say is...

It is an extremely bad idea to encourage people to use the command
sudo passwd root

You could accidentally allow any application (for example a web browser) to have unlimited control over all aspects of your computer.

amacater
Posts: 9
Joined: Sun Apr 15, 2012 7:29 pm

Re: A real AB question: How do I 'run as root'

Sun May 20, 2012 3:35 pm

Vanilla Debian install now has an option: there is the option to set up a root account or not.
If you do not choose to set up a root account, sudo will be set up for the first user.
The Ubuntu way is to set up the first user with the ability to use sudo to get root-equivalent privileges.

The root account still exists: if you login as pi with password raspberry and then

sudo su - ; passwd root

you'd be able to set a root password. If you want to setup a new user with sudo:

sudo su -
adduser <name of new user> and follow prompts.

then

visudo

and add your new username in the /etc/sudoers file in exactly the same way as the pi user is already set up.

Exit out of the session as pi and log in as your new user. Check that you can become root as your new user by using sudo -su

If you can, then run userdel -r pi - this removes the pi user and makes your system slightly more secure (every Pi image for Debian has the same user.). Visudo to remove pi from the /etc/sudoers list

User avatar
meltwater
Posts: 1015
Joined: Tue Oct 18, 2011 11:38 am

Re: A real AB question: How do I 'run as root'

Thu May 24, 2012 7:40 am

Hi

Thanks for the tips so far, the sudo debian fix works very well.

I've come across a tutorial which suggests using the commandline:
sudo gparted

Now, I guess with the above fix, there is no difference to running this through the menus. However, it was mentioned that running gui programs through the commandline isn't favoured, so should that command be avoided?

Also, good point about changing the default user, this will be important to mention when people set up SSH and VNC access.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: A real AB question: How do I 'run as root'

Thu May 24, 2012 9:20 am

There is no problem using the commandline to start GUI applications. In the KDE and Gnome worlds there are GUI versions of sudo for use in GUI launchers. I don't know if LXDE has one although it would be a trivial bit of code to write (once you got your head around how *nix does user-level security.)

The big no-no is starting X as root. Then every program you start will run as root, including your browser and your email client.

rodonn
Posts: 12
Joined: Mon May 28, 2012 4:00 pm

Re: A real AB question: How do I 'run as root'

Sat Jun 16, 2012 4:12 pm

Only time I've seen this sort of error is when the menu is using gksu rather than gksudo.
LXDE uses the gnome back end for a lot of stuff, so I assume it's that.

Gparted and synaptic both seem to have this problem.

rodonn
Posts: 12
Joined: Mon May 28, 2012 4:00 pm

Re: A real AB question: How do I 'run as root'

Sat Jun 16, 2012 4:54 pm

Looking at the gparted.desktop, it is executed as gksu gparted, synaptic, when you install it is installed with su-to-root -X -c /usr/sbin/synaptic
As they stand, neither will accept 'raspberry' as the password.
Changing the entry to 'gksudo' on both results in access without root p-word.

As a comment the .desktop files are superficially quite daunting, but, really, all the interesting stuff is in the last 5 lines.
They're in the /usr/share/applications/.

Return to “Beginners”