Change Prompt Name in Red Hat

Save

Shell prompt names define how the prompt in the terminal appears when the user opens their shell. On Red Hat (and most other forms of Unix and Linux), prompt names are defined by the PS1 to PS4 environment variables. PS1 defines the main prompt, while PS2-4 define less common prompts, such as the prompt that appears when commands take up multiple lines. These can be changed at any time by assigning the environment variable a new value, but they must be made permanent by altering the "/etc/bashrc" file.

  • Open the file "/etc/bashrc" in your favorite text editor.

  • Alter the "PS1=" line to contain your desired prompt. Any text you put here will appear in all your prompts. There are dozens of special values that you can add to the prompt as well, such as "\u" for the name of the current user and "\t" for the current time. For the sake of example, change it to read:

    PS1="\u@\w > "

    This will make it so that, whenever the terminal is opened, the command prompt will read "username@working_directory > ". Any text you type will appear, and escape codes such as "\u" for username and "\w" for "working directory" can be used to display important information.

  • Save the file and open a new terminal. The new prompt will appear.

Tips & Warnings

  • Environment variables can be defined on the fly by typing the command "export VARIABLE_NAME=VARIABLE_DATA." So, to test out a new prompt immediately, you would type 'export PS1="prompt".'

References

Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!