autologin in text mode

Hi all
I have a hp thinclient t620 with OS15.4 installed. It runs nicely and does what it is supposed to do: after logging in, it automatically starts mocp, starts playing the first file from a playlist. I’d like to be able to start the t620 through wol and do the same with autologin in text mode.

I followed these brief instructions:

zypper in mingetty
echo "NO_PASSWORD_CONSOLE tty1" >> /etc/login.defs
echo "1:2345:respawn:/sbin/mingetty tty1" > /etc/inittab

“/etc/inittab” didi not exist on the t620 , hence the echo “” >/etc/inittab.

However, when rebooting, I am always prompted a login. How can I convince OS to do autologin in text mode?

greez
chris

Hi
Using systemd is a little different :wink:


mkdir -p /etc/systemd/system/getty@tty3.service.d

{create a file with the service contents}

vi /etc/systemd/system/getty@tty3.service.d/autologin.conf

[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin <username> %I $TERM

I tested this on ALP, so used tty3, then switched with ctl+alt+F3 and I’m logged in.

I do not know how to do this, but looking into /etc/inittab is a dead alley. It is not used anymore, regardless if you create it or not. Better look into systemd.

Malcolm, Henk
Thanks for the quick reply.

First, based on Henks comment, I undid all my above stated changes

I created the file “/etc/systemd/system/getty@tty3.service.d/autologin.conf” as mentioned, replacing <username> with the user’s name.
then I did:


systemctl enable getty@tty3
Created symlink /etc/systemd/system/getty.target.wants/getty@tty3.service → /usr/lib/systemd/system/getty@.service.

systemctl start getty@tty3

systemctl status getty@tty3
getty@tty3.service - Getty on tty3
     Loaded: loaded (/usr/lib/systemd/system/getty@.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-10-10 18:17:14 CEST; 42s ago
       Docs: man:agetty(8)
             man:systemd-getty-generator(8)
             http://0pointer.de/blog/projects/serial-console.html
   Main PID: 1535 (agetty)
      Tasks: 1 (limit: 4915)systemctl enable getty@tty3
     CGroup: /system.slice/system-getty.slice/getty@tty3.service
             └─ 1633 /sbin/agetty -o "-p -- \\u" --noclear tty3 linux
reboot

No joy. Must still be missing something. What puzzles me is, that “1633 /sbin/agetty -o “-p – \u” --noclear tty3 linux” does not state the username and “–autologin” is also omitted.

Looking at, I fould the options :
**-a, **–autologin **username
-o, --login-options ‘-h darkstar – \u’**So, I ask myself, is “-o ‘-p -f – \u’ --noclear --autologin <username>” correct? Shouldn’t it be
“-o ‘-p -f <username> \u’ --noclear”?

Any Ideas?
greez
chris

Hi
No enabling needed (roll that change back), just add and boot, then switch to the tty3, like I indicated I’m on ALP with my test system, which worked. Try tty1 or tty2 (rename the directory).

Malcolm
Thanks, So I did:

systemctl disable getty@tty3 
Removed /etc/systemd/system/getty.target.wants/getty@tty3.service.

reboot

still no joy.
greez
chris

Hi
Can you check the journal logs;


journalctl -b

[FONT=monospace]journalctl -b | grep -Ei "agetty|tty|login|<username>" 
Okt 10 19:42:06 T620B kernel: printk: console **tty**0] enabled 
Okt 10 19:42:13 T620B systemd[1]: Created slice Slice /system/ge**tty**. 
Okt 10 19:42:15 T620B systemd[1]: Starting Generate issue file for **login** session... 
Okt 10 19:42:16 T620B systemd[1]: Starting User **Login** Management... 
Okt 10 19:42:16 T620B systemd[1]: Finished Generate issue file for **login** session. 
Okt 10 19:42:16 T620B systemd-**login**d[925]: New seat seat0. 
Okt 10 19:42:16 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event8 (Power Button) 
Okt 10 19:42:16 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event7 (Power Button) 
Okt 10 19:42:16 T620B systemd[1]: Started User **Login** Management. 
Okt 10 19:42:17 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event0 (ASIX Electronics AX68004) 
Okt 10 19:42:17 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event2 (ASIX Electronics AX68004 System Control) 
Okt 10 19:42:17 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event3 (ASIX Electronics AX68004 Consumer Control) 
Okt 10 19:42:18 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event5 (Logitech MX Master) 
Okt 10 19:42:18 T620B systemd-**login**d[925]: Watching system buttons on /dev/input/event6 (Logitech K800) 
Okt 10 19:42:26 T620B systemd[1]: Starting **Login** and scanning of iSCSI devices... 
Okt 10 19:42:26 T620B systemd[1]: Finished **Login** and scanning of iSCSI devices. 
Okt 10 19:42:28 T620B systemd[1]: Started Ge**tty** on **tty**1. 
Okt 10 19:42:28 T620B systemd[1]: Reached target **Login** Prompts. 
Okt 10 19:44:23 T620B systemd-**login**d[925]: New session 1 of user root.
[/FONT]

The file is *huge", thus I grepped for what I thought was relevant. I waded through the whole file, too. But imho, there is nothing showing that “getty@tty3” gets called.

I put an echo command into “/etc/systemd/system/getty@tty3.service.d/autologin.conf”:

cat autologin.conf  
[Service] 
#ExecStart= 
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin stim %I $TERM  
echo "getty@tty3 $date was run" >> /tmp/gettytty3.log

reboot

[FONT=monospace]LANG=C ls /tmp/gett* 
ls: cannot access '/tmp/gett*': No such file or directory

[FONT=monospace]systemctl status getty@tty3  
**●** getty@tty3.service - Getty on tty3 
     Loaded: loaded (/usr/lib/systemd/system/getty@.service; disabled; vendor preset: enabled) 
     Active: **active (running)** since Mon 2022-10-10 20:03:30 CEST; 4min 15s ago 
       Docs: man:agetty(8) 
             man:systemd-getty-generator(8) 
             http://0pointer.de/blog/projects/serial-console.html 
   Main PID: 1554 (agetty) 
      Tasks: 1 (limit: 4915) 
     CGroup: /system.slice/system-getty.slice/getty@tty3.service 
             └─ 1554 /sbin/agetty -o "-p -- \\u" --noclear tty3 linux
[/FONT][/FONT]

Where to go from here?

Greez
chris

I ran “systemctl edit --full [noparse]getty@tty1.service[/noparse]” and added both “-f” and “–autologin karl” to ExecStart:

**6700K:~ #** systemctl status getty@tty1.service  
**●** getty@tty1.service - Getty on tty1 
     Loaded: loaded (/etc/systemd/system/getty@tty1.service; **enabled**; preset: **disabled**) 
    Drop-In: /usr/lib/systemd/system/getty@tty1.service.d 
             └─__20-defaults-SUSE.conf 
     Active: **active (running)** since Mon 2022-10-10 19:08:40 CEST; 3min 46s ago 
       Docs: man:agetty(8) 
             man:systemd-getty-generator(8) 
             http://0pointer.de/blog/projects/serial-console.html 
   Main PID: 1019 (login) 
      Tasks: 0 (limit: 4915) 
        CPU: 6ms 
     CGroup: /system.slice/system-getty.slice/getty@tty1.service 
             ‣ 1019 "login -- karl" 

Oct 10 19:08:40 6700K systemd[1]: Started Getty on tty1. 
**6700K:~ #**

Using the command reduces the odds of something going wrong.

Karl,
you mean like that?

cat /etc/systemd/system/getty@tty3.service | grep -i execstart
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear %I $TERM -f --autologin <username>

Greez
chris

Strange also:

journalctl -u getty@tty3 
-- No entries --


You should of course NOT have <username>, but the username that needs to login.

Also I do not understand the \u. The man page says \u. And as it is already escaped by being quoted with ’ … ', …

**6700K:~ #** **grep Exec /etc/systemd/system/getty@tty1.service**  
**Exec**Start=-/sbin/agetty -o '-p **-f** -- \\u' --noclear **--autologin karl** %I $TERM 
**6700K:~ #**

It is coming in bits and pieces, because there is so much ??? there.

As Karl (and others) have shown and as the man page says: first the options with their values and then the other arguments.

@Henk

  • Sure, <username> stands for my actual username, see below
  • I was puzzled about “\u” too. However Karl posts this as well

@ Karl

  • Yep, moved the -f option accordingly:
*grep /etc/systemd/system/getty@tty3.service.d/autologin.conf*  

[FONT=monospace]**Exec**Start=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin stim %I $TERM
[/FONT]
  • I guess you got a >file< /etc/systemd/system/getty@tty1.service.d
    while I have a directory (as per and based on Malcolm suggestion).

I will try to use Karls approach and report back.
greez
chris

SOLVED!

Thanks to Karl!

replace <yourusername> with the username of the user you want to autologin

cat /etc/systemd/system/getty@tty1.service
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service

# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0

[Service]
# the VT is cleared by TTYVTDisallocate
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
ExecStart=-/sbin/agetty -o '-p  -f -- \\u' --noclear --autologin ***<yourusername>*** %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
IgnoreSIGPIPE=no
SendSIGHUP=yes

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION

[Install]
WantedBy=getty.target
DefaultInstance=tty1

greez
chris

As I ran “systemctl edit --full [noparse]getty@tty3.service[/noparse]” I don’t have any dropins:

6700K:~ # **find /etc/systemd/system -type f**
/etc/systemd/system/btrfs-scrub.timer.d/schedule.conf
/etc/systemd/system/btrfs-balance.timer.d/schedule.conf
/etc/systemd/system/wpa_supplicant@.service
/etc/systemd/system/dup.service
/etc/systemd/system/HDD-disable.service
**/etc/systemd/system/getty@tty1.service**
6700K:~ # 

I have a single override with “ExecStart=…” changed:

6700K:~ # **diff /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty@tty1.service**
39c39
< ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear %I $TERM
---
> ExecStart=-/sbin/agetty -o '-p **-f** -- \\u' --noclear **--autologin karl** %I $TERM
6700K:~ # 

Thanks a ton Karl but also Henk and Malcolm!

Greez
chris