• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 7 : How to disable all tty consoles and enable only 1

By admin

Upon system bootup there should be a single tty console running Xorg on it. New tty consoles are generated upon its access dynamically. the tty1 is always reserved for the xorg process and thus can not be disabled.

# ps -ef | grep tty
root      11718  11710  0 Nov01 tty1     00:00:16 /usr/bin/Xorg :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-sKPFMh/database -seat seat0 -nolisten tcp vt1

tty basics

– One can switch from tty1 to tty6 using Ctrl+Alt+F[1-6].
– This continues upto tty6 i.e. default number of allowed tty consoles are 6. ttys are managed by systemd in CentOS/RHEL 7.
– tty consoles are created on-the-fly upon access.
– The allowed number of consoles can be configured in /etc/systemd/logind.conf file.

Disable all tty consoles

1. Edit /etc/systemd/logind.conf file to set the value of the two parameters as shown below.

# vi /etc/systemd/logind.conf
NAutoVTs=0
ReserveVT=N

Here,
NAutoVTs – set this to a desired number to have systemd capable of generating those many tty consoles. Defaults to 6. When set to 0, automatic spawning of autovt services is disabled.
ReserveVT – Takes a positive integer. Identifies one virtual terminal that shall unconditionally be reserved for autovt@.service activation. Defaults to 6 (in other words, there will always be a “getty” available on Alt-F6.). When set to 0, VT reservation is disabled.

Note : N is the number of tty you want to enable. It takes positive integer value. tty1 can not be disabled as it is used by xorg process and it is hardcoded.

Enable a tty console

1. To enable a single tty console set the below parameters in the file /etc/systemd/logind.conf.

# vi /etc/systemd/logind.conf
NAutoVTs=0
ReserveVT=1

2. Create a symbolic link of a tty you want to enable in /etc/systemd/system/getty.target.wants

# ln -sf /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyN.service

3. Enable the tty using systemctl:-

# systemctl enable getty@ttyN.service

4. Reboot the system.

# shutdown -r now

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to install and start the Apache httpd service
  2. RPM command examples to query, install, remove and upgrade packages
  3. Apache HTTP server – most commonly used containers (special configuration directives)
  4. How to find and delete files older than some particular time period in Linux
  5. When to use rescan-scsi-bus.sh -i (LIP flag) in CentOS/RHEL
  6. How to Run a Script When USB Devices Is Attached or Removed Using UDEV
  7. How to add a Custom Script to systemd in CentOS/RHEL 7
  8. How to configure iSCSI Initiator (client) in CentOS / RHEL 7
  9. How to Disable NetworkManager in CentOS/RHEL 8
  10. Linux OS Service ‘avahi-daemon’

You May Also Like

Primary Sidebar

Recent Posts

  • Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  • How To Add Timestamps To dmesg Kernel Boot Log in CentOS/RHEL
  • How to disable ICMP redirects on CentOS/RHEL
  • What are Oracle Key Vault Roles
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary