6

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

6
  • 4
    This is a major security hole. Why do you want to do this? Commented Apr 9, 2016 at 20:54
  • 1
    to save time, because always login as root anyway Commented Apr 9, 2016 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. Commented Apr 9, 2016 at 21:00
  • 2
    If you're using a Unix based OS and logging in as root regularly you're doing it wrong. Commented Apr 10, 2016 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. Commented Apr 11, 2016 at 21:16

3 Answers 3

6

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

Edit the file /lib/systemd/system/[email protected] 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

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"

4
  • 3
    I know, but Pi-user isn't root and needs sudo-command and I was asking automatically login as root... Commented Apr 11, 2016 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) Commented May 26, 2016 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 ? Commented Dec 23, 2016 at 11:37
  • 1
    Q: How to login as root? A: Login as pi. This doesn't answer the question, regardless of which is a better idea. Commented Dec 1, 2017 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.

2
  • 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. Commented Apr 10, 2018 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. Commented Apr 10, 2018 at 16:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.