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
- In Ubuntu, open Terminal and give the following command to edit the .bashrc file.
- The .bashrc file will open in edit mode in the editor.
- Then press Ctrl+F to find PS1 and comment all the occurrences of PS1.
- 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:
- 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.