2

If I switch to a tty, say tty3, it asks me for a username and then for the corresponding password.

How can I achieve, that (only on tty3) it asks me just for a password for a pre-defined user name (say myuser) and mentions the username, for example password for myuser? So I don't need to type the username but just the password on that tty.

I am using ubuntu 18.04 which uses systemd.

6

You'll need to add which distribution you are using, because different distributions probably run getty in different ways.

For sysvinit, it is programmed in /etc/inittab, where you may find a line like the following:

3:23:respawn:/sbin/getty 38400 tty3

You would change that line into something like the following:

3:23:respawn:/sbin/getty -n -o ferdinand 38400 tty3

So as to cause getty to run /bin/login -- ferdinand, i.e., to prime it with the user name "ferdinand".

As documented on man getty, the -n option tells it to not prompt for username, and the -o ferdinand option tells it to add "ferdinand" to its login sub command line.

I would think the options work the same in other distributions, but the way of starting getty for tty3 may well be different and in particular not be using /etc/inittab.

1

The systemd equivalent to the answer by Ralph Rönnquist is to type

sudo EDITOR=/usr/bin/vi systemctl edit getty@tty3

(or your favourite editor). This gives you a temporary file in which you enter the lines:

 [Service]
 ExecStart=
 ExecStart=-/sbin/agetty -n -o ferdinand %I

and exit the editor. It will create the file /etc/systemd/system/getty@tty3.service.d/override.conf. Note, you need the first ExecStart= line to reset the list of commands to execute back to empty. You can then enable and start the Unit as usual:

sudo systemctl enable getty@tty3
sudo systemctl start getty@tty3

The first creates a link in /etc/systemd/system/getty.target.wants/ for the future. See archlinux.

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.