How to customize Terminal in Ubuntu

This tutorial will show you how to customize the look and feel of Terminal in Ubuntu. The second part of the article can also be applied to any other distribution.

Terminal in Ubuntu, or in any GNU / Linux distribution, is a very essential tool. Terminals are tools used to control, manipulate and manage the entire system or even a group of systems.

Although it may seem like just a prompt for host-name and user-name, the Terminal interface has been improved over the years and is aesthetically pleasing in most graphic distributions today. Today, Quantrimang.com will explain how users can customize the look and feel of Terminal in the most commonly used distribution, Ubuntu. The last part of this article can also be used in any other distribution.

How to customize Terminal in Ubuntu?

  1. Use the 'Preferences' option
    1. 1. Text
    2. 2. Colors
    3. 3. Scrolling
  2. Customize using the .bashrc file
    1. Edit sections and layout
    2. More colors
    3. The part shows the colors
    4. Edit .bashrc

Use the 'Preferences' option

Ubuntu's terminal has a 'Preferences' option that can be used to customize the Terminal to some degree. This option can be accessed by right clicking on an empty area in Terminal and selecting 'Preferences'.

Picture 1 of How to customize Terminal in Ubuntu

There are many options listed in many tabs. They have been listed and explained exactly below:

1. Text

Let's explore the basic capabilities of changing the text style in Terminal and a few other options.

  1. Terminal size (about rows and columns)
  2. Font and font size
  3. Space between cells
  4. Pointer shape and flashing mode

Picture 2 of How to customize Terminal in Ubuntu

2. Colors

The available changes are:

  1. Colored themes available
  2. Default background and foreground (text) colors
  3. Bold text, cursor, and highlighted text color
  4. Sliders (slider) throughout

Picture 3 of How to customize Terminal in Ubuntu

3. Scrolling

The options here are:

  1. Toggle scroll bar on / off
  2. Roll based on output (the cursor will go to the bottom if there is a new output)
  3. Scroll based on pressing a key (the cursor will go to the bottom if any key is pressed)
  4. Roll limit

Picture 4 of How to customize Terminal in Ubuntu

Those are all options provided by default for changes in Terminal.

Customize using the .bashrc file

Edit sections and layout

Every Linux distribution has a custom Bash profile file in the Home directory. It can be used (very widely) to change the appearance and function of the command prompt. The prompt is the section that appears after the user logs in to the user account. The default Ubuntu prompt looks like this:

Picture 5 of How to customize Terminal in Ubuntu

The first part is the username, followed by the symbol '@' and host-name (the name of the system / server). Then there is the location of the working directory and finally the '$' sign , indicating that it is not the root user. Instead, the root user has the '#' symbol .

In a nutshell, the default prompt looks like the following:

 user@system-name:working_directory$ 

This prompt is indicated by the name 'PS1'. The Bash profile file can be used to customize the PS1 prompt in several ways.

The default prompt looks like this:

 u@h:w$ 

It is explained as follows:

  1. u: User name of the user
  2. @ : Icon @
  3. h: Host-name of the system
  4. ':': Icon ':'
  5. w: The path of the working directory
  6. $: The '$' symbol.

All of the above creates the default prompt layout. Now, some other options are as follows:

  1. d: Date in the format 'Day / month / day' (example: Tue October 1).
  2. t: Time in HH: MM: SS format.
  3. n: A new line (go to the next line)

A wider list is available here:

 https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Controlling-the-Prompt 

Now that you've learned a little more and can practice trying these. However, to be safe, save the current format with this command:

 DEFAULT=$PS1 

The above command stores the current format of PS1 in variable 'DEFAULT' . Now, if I wanted to try making the username appear in the prompt, what would it look like? According to the code, it is just 'u'. Therefore, you must enter the following command:

 PS1="u$ " 

'$' is essential and serves as a boundary. The expected results are shown as follows:

Picture 6 of How to customize Terminal in Ubuntu

You can even add Bash commands to display in the prompt. That can be done in the following way:

 PS1="[`uname -sr`] u$ " 

Picture 7 of How to customize Terminal in Ubuntu

The command used, which is uname -sr , exports the Linux Kernel version. Similarly, you can use many other commands. You can also add simple text like this:

 PS1="(Phần văn bản mẫu) u$ " 

Picture 8 of How to customize Terminal in Ubuntu

Picture 9 of How to customize Terminal in Ubuntu

You can now return to the original layout using:

 PS1=$DEFAULT 

More colors

Now, you can move on to the more difficult things, which are the actual .bashrc file. If the PS1 variable is set there, it should look like this:

 [3[01;32m]u@h[3[00m]:[3[01;34m]w[3[00m]$ 

Don't worry, this is also quite simple. You can see right away that there is a pattern here. Open with " [" and close with " ]" . Also, there is always a '033' before the sequence of numbers and other symbols. So what do they mean?

"[" and "]" indicate that the characters included are nonprinted characters and represent some of the text's formatting. It applies up to another format bracket, like itself or to the entire following (if no other format is applied).

'033' denotes the color formatting and appearance of the text.

The part shows the colors

The parts shown in color are the numbers ending in 'm'. So 'xxm' will indicate a color. Some standard colors are:

  1. 30: Black
  2. 31: Red
  3. 32: Green
  4. 34: Blue
  5. 37: White
  6. 35: Purple
  7. 33: Gold

A more detailed list can be found easily.

The article mentions almost everything, the rest are just numbers before the semicolon that some colors have. They represent specific text formats, such as bolded text, underlining, etc. Some code includes:

  1. 0 : Normal text
  2. 1 : The text is in bold
  3. 4 : Underlined text
  4. 2 : Translucent text
  5. 8 : Hidden text

Finally, try to create a username, which is red and in bold. The command will look like this:

 PS1="[3[1;31m]u$ " 

Picture 10 of How to customize Terminal in Ubuntu

Let's parse this one last time:

  1. [: Open format brackets
  2. 033: Indicates that this will format the text color.
  3. [first; 31m : Indicates that the text must be in bold and red.
  4. ]: Close the format braces
  5. u: Get a username

NOTE : Please keep in mind that square brackets opened after '033' are not allowed to close.

Now for the final part, manipulate everything you've learned to create the perfect PS1 format for yourself and add it permanently in the following way:

 nano ~/.bashrc 

Go to the end of the file and enter the desired PS1 format.

Picture 11 of How to customize Terminal in Ubuntu

Edit .bashrc

Press CTRL + X Press Y. Then press Enter to save the file.

Picture 12 of How to customize Terminal in Ubuntu

Above is (almost) everything you need to know about customizing Terminal. The latter part of the article can go much deeper, but is still kept in a limit so that users are not confused. Hope you like this article!

Hope you are succesful.

5 ★ | 1 Vote

May be interested

  • How to Install HandBrake on Ubuntu 14.04How to Install HandBrake on Ubuntu 14.04
    handbrake is a free, open-source program used to convert video files. it's available for windows, os x and ubuntu. this article will explain how to install it in ubuntu 14.04. open a terminal window. this is usually done by pressing .
  • How to Customize Linux TerminalHow to Customize Linux Terminal
    it seems like no matter what distribution you use, the terminal emulator is the most boring thing. the good thing you can do is make it look a little better with lots of customization options.
  • How to customize Windows Terminal applicationHow to customize Windows Terminal application
    with the new windows terminal application, windows finally has a tabbed terminal that can run command prompt, powershell and bash in the same window. and it's highly customizable, you can even set animated gifs as wallpapers.
  • How to use ChatGPT from Ubuntu Terminal using ShellGPTHow to use ChatGPT from Ubuntu Terminal using ShellGPT
    artificial intelligence has emerged as a phenomenon in the new age. with new features added daily, there's a lot to look forward to.
  • How to Install Ubuntu Tweak 0.5.1 in UbuntuHow to Install Ubuntu Tweak 0.5.1 in Ubuntu
    if you wanna to install this package manually, just go to their homepage. there you will be able to see which versions are available and which version you need. second way is to install this application through terminal using three simple...
  • How to reset Windows Terminal to default settings on Windows 10How to reset Windows Terminal to default settings on Windows 10
    windows terminal allows you to customize many different setup options. this is also the highly appreciated factor of this tool. however, if i have made too many changes to the windows terminal and want to revert to the default settings, what should i do? ,
  • How to set Windows Terminal to always open with Command Prompt on Windows 11How to set Windows Terminal to always open with Command Prompt on Windows 11
    windows terminal is a great application on windows 11 for you to access operating system commands. windows terminal is a powerful all-in-one solution for programmers as well as professional users.
  • What's New in Ubuntu 21.10?What's New in Ubuntu 21.10?
    version 21.10 is the latest release of ubuntu and although canonical is turning more attention to the cloud and developers, ubuntu 'impish indri' still comes with some notable changes for those users use the ubuntu desktop every day.
  • How to check available memory in UbuntuHow to check available memory in Ubuntu
    linux, bsd and * nix operating systems in general, provide users with many options to view information within the system. just open a terminal and type cat / proc / cpuinfo, cat / proc / meminfo or cat / proc / net / wireless.
  • 6 interesting terminal commands on Mac6 interesting terminal commands on Mac
    terminal is a handy utility, often found on unix-based computers, such as linux and macos. there are many interesting things to do in the terminal. regardless of your experience, you can use these great terminal commands on mac.