8

Is there any simple and straightforward way in which I can set my Debian 8.2 box to automatically login, at startup, with the root account on the console?

There is no GUI installed on the machine.

Following instructions from Automatic root login in Debian 6.0 without GUI (xserver) does not work (files don't exist, options are deprecated).

0

3 Answers 3

15

The file /etc/inittab is not used under systemd any longer. If you wanted, you could install systemv and you would find yourself a brand new inittab, but this would mean walking backward like crabs.

You can instead edit the file /lib/systemd/system/[email protected] and change the line

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

to

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

This just follows from the agetty manual page, which states, among other things:

-a, --autologin username

Log the specified user automatically in without asking for a login name and password. The -f username option is added to the /bin/login command line by default. The --login-options option changes this default behavior and then only \u is replaced by the username and no other option is added to the login command line.

To be sure, I just tested this on my Debian VM, and it works fine.

2
  • 1
    Was looking for inintab replacement on systemd, good answer!
    – Alfabravo
    Sep 8, 2015 at 14:52
  • Still works in Debian 9. Tested in combination with nfsroot on some diskless boxes. And I recommend to keep in mind Arnie97's advice (I am commenting here, as this is the route I've taken, I'm just that lazy for the moment :-)
    – frr
    Aug 7, 2019 at 14:48
13

DO NOT edit the units in /lib/systemd directly, since those are managed by installed packages, and would be overwritten during package upgrades.

Instead, use $ sudo systemctl edit [email protected] to create a drop-in unit at /etc/systemd/system/[email protected]/override.conf with the following contents:

[Service]
ExecStart=
ExecStart=-/sbin/agetty --noclear --autologin your_user_name %I $TERM

It has the same effects as @MariusMatutiae's answer, but won't be touched during system upgrades.

The first line selects the [Service] section to override. The second line explicitly clears the ExecStart entry -- otherwise the original ExecStart in /lib/systemd would still be effective, since multiple ExecStart directives are allowed in a single oneshot service unit. And the last line defines the new ExecStart command line, which is already explained in @MariusMatutiae's answer.

Refer to the systemd.unit(5) manual pages for more details and examples.

-1

You can edit the file /lib/systemd/system/[email protected] and change the line

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

to

ExecStart=-/sbin/agetty --skip-login --login-options "-f root" %I 38400 linux

for auto login as root user

1
  • 3
    I see you're new here, this question has already been answered and you just copied the answer..
    – Gizmo
    May 30, 2018 at 10:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .