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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. tlp: command not found
  2. synopkg Command Examples in Linux
  3. getfacl Command Examples in Linux
  4. “-bash: firewall: command not found” – How to resolve in CentOS/RHEL 7
  5. CentOS / RHEL 5 : How to rebuild Initial Ramdisk Image
  6. What are SELinux Users and how to Map Linux Users to SELinux Users
  7. lslocks: command not found
  8. viewnior Command Examples in Linux
  9. debootstrap Command Examples in Linux
  10. “aws s3 ls” Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • cf: Command-line tool to manage apps and services on Cloud Foundry
  • certutil: Manage keys and certificates in both NSS databases and other NSS tokens
  • cdk: A CLI for AWS Cloud Development Kit (CDK)
  • cd: Change the current working directory

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright