How do I disable switching to virtual terminals (TTYs) using(Ctrl+Alt+F1...F6) in Ubuntu?
-
1I guess you should take a look at this answer to How can I reduce the number of TTYs?– arsaKasraOct 12, 2013 at 7:40
-
1Out 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!– Kyle StrandMar 12, 2016 at 0:32
6 Answers
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.
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
-
9Note 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
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
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
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 "['']"
It can be disabled in dconf-editor too:
Search "switch-to-session", in dconf-editor;
Select each item of "switch-to-session-1" to "switch-to-session-12";
For each item, turn off "Use default value", and set "Custom value" to "[]";
Search in dconf-editor:
Set custom value for each item: