Xterm is a terminal that everyone will love because it is fast, lightweight, and pretty efficient with computing resources.
In this tutorial, you will learn how to install xterm on Ubuntu and also how to customize xterm, to make sure you can take full advantage of the xterm terminal.
What is Xterm
Xterm is a terminal emulator designed for the X Window System. Being one of the oldest terminal emulators, Xterm is still in use to this day. Its first version was released in 1984, which is quite old. Even though it’s an old terminal emulator, Xterm is still regularly maintained.
Xterm is a super lightweight terminal that can run without taking many computer resources. It’s a great terminal for computers with limited hardware.
Not only is Xterm lightweight, but it is also highly customizable, allowing you to personalize its appearance according to your preferences.
Xterm Features
- Compatibility. Xterm is highly compatible with various Unix-like systems making it widely available on many Operating Systems such as Linux or FreeBSD.
- Lightweight. Designed to be efficient and fast, Xterm tends to have less memory footprint and resource usage. This makes it perfect for any computer or even one with lower hardware specifications.
- Customizability. Although it’s a lightweight terminal, Xterm still offers great customization options, giving you full control over its appearance and behavior.
- Multiple Windows Support. With multiple windows support, you can open multiple terminal windows making it easier to work on different terminal instances simultaneously.
- Key Bindings. Xterm allows you to customize the keyboard shortcuts to do various actions. This makes your navigation through the terminal much more efficient.
Install Xterm on Ubuntu
To install Xterm on Ubuntu is not complicated, for this tutorial, I’m using Ubuntu 22.04 but you can use other versions of Ubuntu and the process should be the same.
First, you need to update the package repositories and make sure it is updated with the latest repositories. Simply run the command below to update the package repositories.
sudo apt update
And then, you can start to install xterm on Ubuntu by running the following command:
sudo apt install xterm
The installation process should begin. Just wait until the installation process to complete. Once it is done, the Xterm terminal should be available in the applications menu.
Customize Xterm
The default appearance of Xterm is pretty basic, if you are okay with the basic appearance of xterm, then you can go ahead and just use it as it is. However, if you want a better xterm appearance, You will need to customize it yourself.
Some of the customizations you can do are the fonts, color schemes, and keybindings/keyboard shortcuts. Don’t worry, I will guide you through every step and make sure you can customize your xterm terminal successfully.
Create the Configuration File
Before start configuring the xterm, you will need the .Xresources
file. It is usually located in the home directory. If you ever installed URxvt, you may already have the .Xresources
file. However, if it doesn’t exist, you can create the config file by using the touch
command.
touch .Xresources
Now the .Xresources
file should be available. and You can start configuring the xterm terminal.
Change Xterm Font
To change the font in Xterm is quite straightforward, you just need to edit the .Xresources
file and put the font configuration in there.
For example, if you want to use the Liberation mono
font with the size 12 and with antialiasing turned on, you can use the configuration as below:
xterm*faceName: Liberation Mono:size=12:antialias=true
Or maybe you want to use other fonts, you can lookup for the available fonts you can use by using the fc-list
command.
fc-list | grep "Mono"
But remember, use a monospace font to avoid the characters collapsing into each other.
Once you’ve set the font, save the configuration and run xrdb .Xresources
command on your terminal.
Now restart the xterm terminal and the new font should be applied.
Change Xterm Color Schemes
Xterm provides the ability to customize the terminal color schemes, with this, you can have a better terminal appearance.
There are many options available for setting the colors, including foreground, background, cursor color, and also 16 base terminal colors.
However, the best way to set the color schemes for xterm is by using predefined color schemes. For example, you can use the solarized color schemes below:
! special
*.foreground: #93a1a1
*.background: #002b36
*.cursorColor: #93a1a1
! black
*.color0: #002b36
*.color8: #657b83
! red
*.color1: #dc322f
*.color9: #dc322f
! green
*.color2: #859900
*.color10: #859900
! yellow
*.color3: #b58900
*.color11: #b58900
! blue
*.color4: #268bd2
*.color12: #268bd2
! magenta
*.color5: #6c71c4
*.color13: #6c71c4
! cyan
*.color6: #2aa198
*.color14: #2aa198
! white
*.color7: #93a1a1
*.color15: #fdf6e3
Copy these color schemes, and put them inside the .Xresources
file.
Then run the xrdb .Xresources
command to apply the changes.
The result is much better than the default xterm, isn’t it?
Change the Pointer and Cursor
Xterm also allows you to modify the display of the pointer and cursor. You can change the pointer color and the background color of the pointer. Additionally, you can alter the cursor color and make it blink. For example, you can use the following configuration:
XTerm*pointerColor: white
XTerm*pointerColorBackground: black
XTerm*cursorColor: orange
XTerm*cursorBlink: true
Copy and paste these configurations into the .Xresources
file.
Then run the xrdb .Xresources
command to apply the changes.
These settings will change the pointer color to white and the background color to black. Additionally, the cursor color will be set to orange, and it will blink. Pretty cool isn’t it?
Enable Copy and Paste Keybindings on Xterm
Actually, by default xterm has the ability to copy and paste, but the mechanism is a bit clunky. Basically, to copy the text, you just need to highlight the text, then to paste the text press the middle mouse button.
Therefore, we need to configure the keybinding for copy and paste to make it the same as the keybinding on other terminals. which is CTRL + SHIFT + C
to copy, and CTRL + SHIFT + V
to paste from the clipboard.
To set the keybinding for copy and paste, copy the configuration below and paste it into the .Xresources
file.
xterm*VT100.Translations: #override \
Shift <KeyPress> Insert: insert-selection(CLIPBOARD) \n\
Ctrl Shift <Key>V: insert-selection(CLIPBOARD) \n\
Ctrl Shift <Key>C: copy-selection(CLIPBOARD) \n\
Ctrl <Btn1Up>: exec-formatted("xdg-open '%t'", PRIMARY)
Save the file and then run the xrdb .Xresources
command to apply the changes.
Actually, there are other available keybindings you can set, but for this tutorial, we just need to set the copy and paste keybindings.
See all the available keybindings on the xterm manual page.
Change the Default Window Size
The default window size in xterm terminal is 80×24. But you can easily change the default window size by adding configuration to the .Xresources
file. for example, if you want to set the window size to 90×28 simply use the configuration below:
xterm*VT100.geometry: 90x28
You can also set window size with a custom flag when launching the xterm terminal.
xterm -geometry 90x28
But I believe the first method is the best way to set the default window size, because the change is persistent, unlike the second method.
Uninstall Xterm on Ubuntu
When you don’t need the xterm terminal anymore, you can simply uninstall it from your Ubuntu system by running the following command:
sudo apt remove xterm
After running this command, the xterm terminal should be no longer available on your Linux machine.
Conclusion
Xterm provides a powerful and lightweight terminal to support your need for a terminal emulator. By following this tutorial you should be able to install xterm on the Ubuntu machine and you should be able to configure xterm to get a better experience with xterm terminal.