How to Change Linux Prompt Permanently?

How to Change Linux Prompt Permanently?

  • Linux
  • 1 min read

In Linux, the PS1 system variable is used to change the prompt setting. To change the Linux prompt permanently, you need to modify the .bashrc file which initializes the interactive shell session whenever the system starts. Below I am giving the steps to perform this task. To demonstrate this, I am using an Ubuntu Linux system.

Bash - Change Linux Prompt Permanently

  1. In Ubuntu, open Terminal and give the following command to edit the .bashrc file.
gedit ~/.bashrc
  1. The .bashrc file will open in edit mode in the editor.
  2. Then press Ctrl+F to find PS1 and comment all the occurrences of PS1.
  3. Now to change the Linux prompt, assign a new value to PS1 variable, for example, PS1='$ ', after each line of PS1, which you already commented. As shown in the below image:

Change Linux Prompt permanently.

  1. Save the changes and close the .bashrc file.

Now the Linux prompt has been changed for permanent. Close the Terminal and open it again you will find the changes in the Linux prompt.

See also: