How to set the default terminal (or window manager, browser, and much more) in Linux

Ever wondered how your Linux system chooses the default Terminal Emulator, web browser, window manager, text editor, particular version of an app (eg, php5 vs 7/python2.7 vs 3)? Wonder no more!

Change the default app in /etc/alternatives

The folder /etc/alternatives contains all of the ‘alternative’ applications for a particular type of application. For example, my Terminal application of choice is terminator which is the default ‘alternative’, but what if I wanted to change it back to the original default of gnome-terminal?

The update-alternatives tool

Using the update-alternatives command at the Terminal can change any application default where another application exists for the same ‘class’ of application. For example, the Terminal application exists in the ‘x-terminal-emulator’ class. Your web browser exists in the ‘browser’ class, and so forth. To list the classes, simply do an ‘ls -l /etc/alternatives’, which will show you the list of all the classes, and their currently set alternative.

To use the update alternatives tool and change the default setting for the appropriate ‘class’, use the –config flag, as demonstrated below. This example shows how to set your default emulator (Terminal).  In this example, you can see how I option 0 has an asterisk beside it, denoting that it is the current default. Note that I selected the option 1 to change the default to gnome-terminal.

Example

/etc/alternatives$ sudo update-alternatives --config x-terminal-emulator
There are 9 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator).


Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/terminator 50 auto mode
1 /usr/bin/gnome-terminal.wrapper 40 manual mode
2 /usr/bin/guake 40 manual mode
3 /usr/bin/koi8rxterm 20 manual mode
4 /usr/bin/lxterm 30 manual mode
5 /usr/bin/mate-terminal.wrapper 30 manual mode
6 /usr/bin/stterm 15 manual mode
7 /usr/bin/terminator 50 manual mode
8 /usr/bin/uxterm 20 manual mode
9 /usr/bin/xterm 20 manual mode


Press to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/gnome-terminal.wrapper to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in manual mode

Further reading

For those eagle eyed out there, if you now do an ls -l /etc/alternatives/x-terminal-emulator, you’ll see that the symbolic link has been changed to go to /usr/bin/gnome-terminal.wrapper. This means you could have simply made a symbolic link to make this change, but the tool makes the process even easier.

Check out the man page for update-alternatives: [ https://linux.die.net/man/8/update-alternatives ]

One thought on “How to set the default terminal (or window manager, browser, and much more) in Linux

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.