How to Disable Local Login in Linux

The default installation provides six CLI virtual consoles and one GUI desktop. A virtual console simulates a terminal. A terminal allows us to log in and access the system on CLI. Each terminal enables us to log in with a separate user account. We can log in with six user accounts simultaneously. This feature allows us to test or debug a multiuser service or feature on the same system. Although it is a default and effective tool, some administrators prefer it to be disabled for security or other reasons. This tutorial explains the steps to disable a single or all virtual consoles.

Accessing virtual consoles

The following key combinations allow us to switch between CLI virtual consoles and the GUI desktop.

Ctrl + Alt + F1 GUI
Ctrl + Alt + F (2 to 5) Default virtual consoles
Ctrl + Alt + F6 Reserved virtual console

Disabling virtual consoles

Log in with the root account, access a terminal, and follow the following steps.

  • Create a directory in the /etc/systemd/ directory.
  • Create a configuration file in the created directory.
  • Set the value of the NAutoVTs option to 0.
  • Save the file.
  • Start the service.
#mkdir /etc/systemd/logind.conf.d
#vim /etc/systemd/logind.conf.d/novt.conf

	[Login]
	NAutoVTs=0

	:wq

#cat /etc/systemd/logind.conf.d/novt.conf
#systemctl reload systemd-logind.service

The above steps disable the login feature on all virtual consoles except reserved.

the nautovts option

To verify it, switch between default virtual consoles. If you do not see the login screen on default virtual consoles Ctrl + Alt + F (2 to 5), it verifies the configuration.

login not available

The above configuration does not disable the reserved virtual console. The default reserved console is F6. To verify this, switch to the default reserved console (Ctrl + Alt + F6).

virtual console

Disabling the reserved virtual console

The reserved console allows us to access the system if something goes wrong. We can use it to log in and fix issues. Disabling the reserved virtual console is not recommended. However, if you want, you can do it as well. To disable the reserved console, add the ReserveVT option to the configuration file and set its value to 0.

#vim /etc/systemd/logind.conf.d/novt.conf
	[Login]
	NAutoVTs=0
	ReserveVT=0

	:wq

The login service reserves it during boot time. Restarting the service does not disable the reserved virtual console. A system reboot is required to implement it. Restart the system.

#reboot -f

reserve vritual terminal

After the system reboots, switch to the reserved virtual console (Ctrl + Alt + F6) to verify the configuration.

login not available

Enabling virtual consoles

To enable only the reserved virtual console, open the configuration file, remove the ReserveVT=0 option, save the file, and reboot the system. To enable all virtual consoles, remove the configuration file and restart the system.

enable virtual consoles

Switch to default and reserved consoles after the system reboots.

virtual console

A login screen on these consoles verifies virtual consoles.

Understanding technical concepts

The systemd-logind service manages user logins. It provides the following features and functions.

  • Keep track of user sessions, processes, and states.
  • Provide PolicyKit-based access.
  • Allow users to shut down and hibernate or sleep in the system.
  • Manage session switches and device accesses.
  • Manage and activate login on virtual consoles.

This service supports many options to customize the login process. The NAutoVTs and ReserveVT options allow us to control and manage login on virtual consoles. Both accept positive integers.

The NAutoVTs (Number of Automatically spawned on Virtual Terminals) option defines the number of virtual terminals. The default is 6. The value 0 disables login on all virtual consoles except the reserved. This option does not affect the consoles defined by the option ReserveVT.

The ReserveVT (Reserve Virtual Terminal) option defines the number of reserved virtual terminals. The login service always starts virtual consoles defined by this option.

To view all available options and learn more about the login service, you can check the manual pages on the following web pages.

https://manpages.ubuntu.com/manpages/xenial/man5/logind.conf.5.html
https://manpages.ubuntu.com/manpages/xenial/man8/systemd-logind.service.8.html

Conclusion

In some circumstances, disabling virtual consoles is essential. This tutorial explained the steps to disable virtual consoles and enable them again. Following these steps, you can customize the number of virtual consoles available to log in on a Linux system.

ComputerNetworkingNotes Linux Tutorials How to Disable Local Login in Linux

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com