Post

How to Customize the Terminal Prompt in Linux

How to Customize the Terminal Prompt in Linux

In this article, we will discuss how to customize the terminal prompt in Linux. We will change the hostname part of the prompt from “bnu@DO-LAB05” to “umamazaeem@DO-LAB”.

Step 1: Open ~/.bashrc for Editing

nano ~/.bashrc

Step 2: Find the PS1 Variable

Locate the line that sets the PS1 variable. It will look something like this Modify the \u part which represents the username. Replace \u with sumamazaeemsumamazaeem@DO-LAB. Here’s how it will look:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]sumamazaeem@DO-LAB\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Save the changes by pressing Ctrl+O, then press Enter to confirm the filename to write. Finally, exit nano by pressing Ctrl+X.

To apply the changes immediately, either run:

source ~/.bashrc

This post is licensed under CC BY 4.0 by the author.