4

Is there a way to auto login as root at startup with Raspbian Jessie like there are auto login for user pi?

  • 4
    This is a major security hole. Why do you want to do this? – Steve Robillard Apr 9 '16 at 20:54
  • 1
    to save time, because always login as root anyway – Redex Apr 9 '16 at 20:59
  • 4
    So taking 10 seconds to login is worth hosing your system? There is nothing you can't do as the Pi user with sudo. – Steve Robillard Apr 9 '16 at 21:00
  • 2
    If you're using a Unix based OS and logging in as root regularly you're doing it wrong. – Matti Virkkunen Apr 10 '16 at 20:54
  • 4
    I feel like the downvotes on this question are poor form. It's a foolish choice on Redex's part, but it's not a bad question. – Jacobm001 Apr 11 '16 at 21:16
5

MariusMatutiaes accepted answer worked for Raspbian Jessie (March 2016) too:

Edit the file /lib/systemd/system/getty@.service and change the line

ExecStart=-/sbin/agetty --noclear %I $TERM

to

ExecStart=-/sbin/getty/ --noclear -a root %I $TERM

Reference: https://superuser.com/a/970013

| improve this answer | |
4

I'm not sure why you would want to autologin as root, but if its just for the sake of saving those few seconds you can choose to auto login with the pi username in the raspi-config settings:

Auto Login as "pi"

| improve this answer | |
  • 2
    I know, but Pi-user isn't root and needs sudo-command and I was asking automatically login as root... – Redex Apr 11 '16 at 20:09
  • From a security point of view autologin is a bad choice, but this is moderately better solution (and hence a valid answer) – Steve Robillard May 26 '16 at 20:05
  • I tried this with B2 option and all works as expected. Do you know what files raspi-config actually changes when setting this auto login option ? All I can see it doing is creating a symbolic link between default.target and multi-user.target inside systemd services folders. How does it work ? – Shady Programmer Dec 23 '16 at 11:37
  • Q: How to login as root? A: Login as pi. This doesn't answer the question, regardless of which is a better idea. – NateS Dec 1 '17 at 20:35
1

Just for the sake of completeness, if you need to auto-login to Desktop as root, you can do the following:

  • configure the pi user to autologin using raspi-config
  • replace autologin-user=pi to autologin-user=root in /etc/lightdm/lightdm.conf
  • reboot

Steve already warned about the dangers of root login from security standpoint. When logging to Desktop, more issues arise which will affect even basic usability:

  • PulseAudio will run in system mode, which is slower and has less features (that is, in addition to being less secure)
  • Many software packages will refuse to run as root (at least without hacks), or will be missing essential features: chromium, tor, and, xscreensaver and many more. Example:

enter image description here

  • graphical file managers will become really dangerous: a single misclick can e.g. drag&drop your /etc inside /lib, completely ruining your system.

  • since root processes are considered more valuable by OOM killer, opening a huge file in GIMP or a buggy webpage in your browser is likely to kill a few innocent processes along the way.

So, even if you don't care about security, you should consider whether saving those 10 seconds to type in sudo is worth all the time you will lose fixing misbehaving software and risking a reboot after each browser crash.

| improve this answer | |
  • I get really tired of this root paranoia, I've been logging in as root for 20 years. Not that I never made a mistake but I didn't do it twice, and I had to fix what I broke or reinstall. – Alan Corey Apr 10 '18 at 15:59
  • 1
    I wouldn't have my mother do it, or most undergrads. Having your processes run with elevated privileges is maybe the worst part. – Alan Corey Apr 10 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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