23

How do I disable switching to virtual terminals (TTYs) using(Ctrl+Alt+F1...F6) in Ubuntu?

2
  • 1
    I guess you should take a look at this answer to How can I reduce the number of TTYs?
    – arsaKasra
    Oct 12, 2013 at 7:40
  • 1
    Out of curiosity, why do you want this? I've got a set of ill-behaved init-scripts that have somehow disabled these and am trying to restore them! Mar 12, 2016 at 0:32

6 Answers 6

30

I found three methods. I'm listing to help others if they need:

First Method:

sudo tee -a /etc/init/tty{1..6}.override <<<"manual"

Second Method:

Open/create the file /etc/X11/xorg.conf using the following command:

sudo -i gedit /etc/X11/xorg.conf

and add the following lines inside:

Section "ServerFlags"
    Option "DontVTSwitch" "true"
EndSection

Third Method:

sudo -i

vi /etc/default/console-setup

change ACTIVE_CONSOLES="/dev/tty[1-6]" to your choice. Lets say if you want only two TTY or virtual console then change to ACTIVE_CONSOLES="/dev/tty[1-2]"

cd /etc/event.d

Comment on all the lines in ttyX file that you don't need. In this example tty3-tty6 Reboot to see the change.

0
17

Open/create the file /etc/X11/xorg.conf using the following command:

sudo -i gedit /etc/X11/xorg.conf

and add the following lines inside:

Section "ServerFlags"
    Option "DontVTSwitch" "true"
EndSection

Source: [all variants] How to disable CTRL ALT F1 - ubuntuforums.org

1
  • 9
    Note that once in a while, when X11 gets stuck, those keys allow you to get out to a console and cleaning shutdown your system... I used that many times although these days I have a lot less problems with X11 getting stuck! Oct 12, 2013 at 8:02
0
sudo rm /etc/init/tty*.conf

This will totally remove the tty* conf file and thus you will not be able to use it :)

NB: you can't be able to restore it later on

0

open the tty conf in the /etc/init/ directory

comment out those lines in the ttyX.conf files:

#respawn 
#exec /sbin/getty -8 38400 ttyX

Example to disable tty1:

sudo -H gedit /etc/init/tty1.conf

Then edit by inserting # in front of the commands

#respawn 
#exec /sbin/getty -8 38400 tty1

Save and Reboot

0

On Gnome Wayland you can unset the keybindings for virtual terminal switching by setting these dconf properties:

dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-1 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-2 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-3 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-4 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-5 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-6 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-7 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-8 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-9 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-10 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-11 "['']"
dconf write /org/gnome/mutter/wayland/keybindings/switch-to-session-12 "['']"
0

It can be disabled in dconf-editor too:

  1. Search "switch-to-session", in dconf-editor;

  2. Select each item of "switch-to-session-1" to "switch-to-session-12";

  3. For each item, turn off "Use default value", and set "Custom value" to "[]";

Search in dconf-editor:

search in dconf-editor

Set custom value for each item:

set Custom value for each item

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .