1

I am trying to set up an alpine linux machine that needs to run an user program at the startup.

I did not add any user except for root.

After searching for solution of how to enable automatic login i have found instructions that said i need to use agetty. In order:

  1. apk add util-linux to add agetty.
  2. cd /etc/init.d && ln -s agetty agetty.tty1 to add agetty service for the terminal.
  3. cd /etc/conf.d && cp agetty agetty.tty1 to add configuration.
  4. nano agetty.tty1 or use other editor to add "--autologin $USER --noclear" to agetty options
  5. rc-update add agetty.tty1 to ensure launch at start.

One thing that bothered me was the fact instruction told about turning off previous agetty service before adding new, changed one - and there was no agetty service enabled.

However, things went wrong: during machine start i could see output of the automatic login before several services (chrony and some other) were started, and then i got another login prompt that did not work anymore. it seemed as there were bno two logins/terminals and system became unworkable.

What was my error and how can i fix this?

2
  • Is this a Docker Container? Commented Jul 10, 2023 at 8:49
  • No, just a standalone computer Commented Jul 10, 2023 at 8:54

1 Answer 1

3

If by "automatic login" you mean "I'd like a root shell without a password", the easiest way to do that is to add something like this to /etc/inittab:

tty1::respawn:/bin/sh 

That will spawn a root shell instead of a login prompt on the given terminal.


To accomplish the same thing using agetty, do exactly what you've done in your question, but don't forget to disable the existing getty service defined in /etc/inittab:

sed -i '/tty1/ s/^/#/` 

Which should get you:

#tty1::respawn:/sbin/getty 38400 tty1 

And then reboot (or kill -HUP 1 to reload /etc/inittab).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.