Text boot without text console: agetty problem in Fedora 36

I have always used text+console boot without graphic interface. This includes the login, that is also text only since I do some sync stuff at login time, specifically on tty1 where I have an autologin script, that executes the following command through the file /etc/systemd/system/getty@tty1.service.d/override.conf:

/usr/sbin/agetty --autologin <myusername> --noclear %I 38400 linux

I just upgraded to Fedora 36 (from 35), and the boot goes fine until the very last step. Instead of showing me a text login prompt, it shows a black screen with an underscore at the top left.


The command systemctl goes well except precisely for one red line:

● getty@tty1.service    loaded failed failed    Getty on tty1

In the logs, I can see an error:

agetty[4565]: /dev/tty1: "cannot get controlling tty: Operation not permitted"
agetty[4565]: setting terminal attributes failed: Input/output error

I can see this error in the console each time I try as root

 service getty@tty1.service start

I don’t know what went wrong, but it seems the agetty command changed?


If I put the line:

ExecStart=-/usr/sbin/agetty --autologin <myusername> --noclear tty1 38400 linux

in the file /etc/systemd/system/getty@tty1.service.d/override.conf the autologin works. Yet, if I change to


with the same line, it doesn’t!!

Asked By: Luis A. Florit


That cannot get controlling tty: Operation not permitted error by agetty is returned by agetty when the TIOCSCTTY ioctl() it makes so the terminal device becomes the controlling terminal of agetty‘s session fails.

It issues that ioctl() if the terminal currently doesn’t control any session, or if it controls a session whose id is not agetty‘s pid.

From the tty_ioctl(2) man page:

      Argument: int arg

      Make the given terminal the controlling terminal of the  calling
      process.   The  calling process must be a session leader and not
      have a controlling terminal already.  For this case, arg  should
      be specified as zero.

      If  this  terminal is already the controlling terminal of a dif‐
      ferent session group, then the ioctl fails  with  EPERM,  unless
      the caller has the CAP_SYS_ADMIN capability and arg equals 1, in
      which case the terminal is stolen, and all processes that had it
      as controlling terminal lose it.

So, it won’t work if agetty is not a session leader.

If you start a script that runs agetty in a child process instead of starting agetty directly, then the shell will be a session leader, and agetty will not.

Using exec agetty will run agetty in the same process as the shell (will replace the shell) and then agetty will be session leader.

If that worked in the previous version of Fedora with the same modus operandi, my guess would be that systemd had already made the terminal device the controlling terminal of the session, may by calling open() on it without the O_NOCTTY flag. But even then, having agetty not being the session leader sounds like a bad idea.

(I stroke that as in that case the controlled session would still not match agetty‘s pid, so it would still try to issue the TIOCSCTTY; I don’t have another explanation for now).

Answered By: Stéphane Chazelas
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.