Linux Commands
How To
Change Prompt
Commands
ls
cd
mkdir
cat
more
head
tail
touch
rm

How to Change Putty / Terminal Prompt in Linux



How to Change Putty / Terminal Prompt in Linux


to change the prompt in linux putty / terminal, you should issue the below command in putty / terminal and press enter.


PS1='MyPrompt:\w> '
export PS1

to save the prompt, add the two lines to your $HOME/.bashrc on the server


examples

prompt with working directory@username


PS1='\w@\u> '

prompt with hostname:working directory@username


PS1='\h:\w@\u> '

Options

OptionDescription
\ddisplays date, in "Weekday Month Date" format (e.g., "Tue May 26").
\hdisplays hostname, first word . (e.g. mymachine) in hostname
\Hdisplays complete hostname
\jdisplays number of jobs currently managed by the shell.
\ldisplays basename of the shell's terminal device name.
\sdisplays name of the shell, the basename of $0
\tdisplays time, in 24-hour HH:MM:SS format.
\Tdisplays time, in 12-hour HH:MM:SS format.
\@displays time, in 12-hour am/pm format.
\udisplays username of the current user.
\vdisplays version of Bash (e.g., 2.00)
\Vdisplays release of Bash, version + patchlevel
\wdisplays current working directory.
\Wdisplays basename of $PWD.
\!displays history number of this command.
\#displays command number of this command.
\$displays $ if user is not root otherwise it displays #
\\displays backslash in prompt
\[Begin a sequence of non-printing characters.
\]End a sequence of non-printing characters.

Coloring Prompt

PS1='\[\e[32m\]\u@\h:\w\[\e[0m\] '

the above prompt change the putty prompt color to Green


f5dafcc419d609_colorprompt.png
Color Codes

CodeDescriptionExample
30Dark GreyPS1='\[\e[30m\]\u@\h:\w\[\e[0m\] '
31RedPS1='\[\e[31m\]\u@\h:\w\[\e[0m\] '
32GreenPS1='\[\e[32m\]\u@\h:\w\[\e[0m\] '
33YellowPS1='\[\e[33m\]\u@\h:\w\[\e[0m\] '
34BluePS1='\[\e[34m\]\u@\h:\w\[\e[0m\] '
35PurplePS1='\[\e[35m\]\u@\h:\w\[\e[0m\] '
36TurquoisePS1='\[\e[36m\]\u@\h:\w\[\e[0m\] '
37Light GrayPS1='\[\e[37m\]\u@\h:\w\[\e[0m\] '


rm

rm command in linux

posted on 2019-10-24 21:34:18 - Linux Commands Tutorials


touch

touch command in linux

posted on 2019-10-23 19:41:20 - Linux Commands Tutorials


tail

tail command in linux

posted on 2019-10-23 19:10:42 - Linux Commands Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials