Linux 7 - RedHat, CentOS - command prompt.

MarGib June 18, 2026
🌐 🇵🇱 Polski · 🇬🇧 EN
If you have ever worked with Linux, you certainly know what a terminal window is. In the terminal, we also have something called a command prompt. For those who don't know, this prompt is the first line where we type our commands. It can take various default forms depending on the distribution, but it is most commonly something like [root@hostname ~] or, for example, -bash4.2#. However, you can easily customize it to display other information for convenience. The prompt can also look like this: [12:45] [root@hostname] [/location] $, where the time, logged-in user, hostname, and current working directory are visible. The prompt can also be colorized. Colors make it more readable and help it stand out from the rest of the command output. The system variable that stores the prompt format is called "PS1"; to see its current format, simply run the command echo $PS1

Step 1 - Setting the prompt to [time] [user@server] [location] 

In the terminal, run the following command: 

export PS1='[\A][\u@\h][\w] $ '

After executing the above, the prompt will look like this: 

[04:13][root@an-server][/opt]

Step 2 - Colorizing the prompt.

In the terminal, run the command that includes color codes so that the time is yellow, the username is green, the hostname is red, and the location is cyan. 

export PS1='[\[\e[0;33m\]\A\[\e[m\]][\[\e[0;32m\]\u\[\e[m\]@\[\e[0;31m\]\h\[\e[m\]][\[\e[0;36m\]\w\[\e[m\]] $ '

Although the above may look quite complex, in reality, everything forms a logical structure. 


If you want to apply coloring in the terminal, the standard pattern used is: 

\e[X;Ym TEXT_TO_COLOR \e[m

Where:
  • \e[ - Starts the coloring
  • X;Y - A pair of colors (listed in the table below)
  • m - Mandatory character
  • \e[m - Character sequence ending the coloring
To find the values for the X;Y pair, you can use the colors.sh script: 

#!/bin/bash

esc="\033["
echo -n " _ _ _ _ _40 _ _ _ 41_ _ _ _42 _ _ _ 43"
echo "_ _ _ 44_ _ _ _45 _ _ _ 46_ _ _ _47 _"

for fore in 30 31 32 33 34 35 36 37; do

line1="$fore "
line2=" "
for back in 40 41 42 43 44 45 46 47; do

line1="${line1}${esc}${back};${fore}m Normal ${esc}0m"
line2="${line2}${esc}${back};${fore};1m Bold ${esc}0m"

done
echo -e "$line1\n$line2"
done




The output will be: 


Step 3 - Saving settings for the user in .bash_profile

If you want the prompt to look as we designed above every time you log into the terminal, the PS1 variable setting must be saved in the .bash_profile file 

#Prompt
export PS1='[\[\e[0;33m\]\A\[\e[m\]][\[\e[0;32m\]\u\[\e[m\]@\[\e[0;31m\]\h\[\e[m\]][\[\e[0;36m\]\w\[\e[m\]] $ '

The final result for the prompt looks like this: 



Useful links:


Facebook X E-mail

Comments

Dodaj komentarz

Explore

Labels

internet 13 Google 10 Linux 9 AI 7 chrome 7 Artificial Intelligence 6 Windows 6 entertainment 6 news 6 God 5 Microsoft 5 Security 5 books 5 browsers 5 new technologies 5 Mind 4 automation 4 coaching 4 technology 4 trivia 4 Android 3 BIG DATA 3 Business 3 FIFA 3 Firefox 3 Opera 3 RedHat 3 Software 3 Windows system administration 3 artificial intelligence 3 bash 3 computer science 3 extensions 3 facebook 3 faith 3 help 3 money 3 people 3 photography 3 reading 3 religion 3 web applications 3 Configuration 2 Drones 2 FAQ 2 Google projects 2 Intel 2 Intelligence 2 LLM 2 Machine Learning 2 Programs 2 Technology 2 Vivaldi 2 ansible 2 applications 2 children 2 cloud storage 2 communication 2 communities 2 computer intelligence 2 computers 2 conferences 2 curiosities 2 data 2 death 2 documentary 2 earning 2 file storage 2 fix 2 games 2 good movie 2 hacker 2 health 2 human 2 investments 2 media 2 mind manipulation 2 mobile apps 2 mobile phones 2 movie 2 multimedia 2 network 2 personal competencies 2 personal development 2 personal thoughts 2 photos 2 plugin 2 shell 2 terminal 2 torrent 2 trick 2 wealth 2 64 bit 1 7 1 AI Frameworks 1 AI History 1 AI Safety 1 AI in sports 1 AIMP 1 Alan Watts 1 Alexander Gerst 1 Anonymous 1 Anthropic 1 Asus 1 Automation 1 Banking 1 Bill Warner 1 Bono 1 C++ 1 CUDA 1 CentOS 1 Centos 1 Chemtrails 1 Claude 1 Claude AI 1 Coaching 1 Constitutional AI 1 Darwin 1 Debian 1 Deluge 1 DevOps 1 Diagnostics 1 Digitalization 1 EA GAMES 1 EA SPORTS 1 Email 1 Emigration 1 FIFA 16 1 Fable 1 Football 1 Free 1 Free Red Hat 1 Future of Finance 1 GUI 1 Generation Z 1 Google activity 1 Got Talent 1 HTML 1 ISIS 1 ISS 1 Intelligent email 1 Islam 1 Islamic State 1 Jacquard 1 Jboss 1 Kali Linux 1 Kylian Mbappé 1 Londoners 1 Maps 1 Medicine 1 My take 1 Mythos 1 NVIDIA 1 Neural Networks 1 Notion 1 Open Source 1 P2P 1 Pac-Man 1 Perceptron 1 Personal Development 1 Personal Finance 1 Personal development 1 Philosophy 1 Poland 1 Poles 1 PowerShell 1 Privacy 1 Productivity 1 Programming 1 Psychology 1 RHEL7 1 Raspberry PI 1 Raspbian 1 Red Hat 1 Red Hat Enterprise Linux Developer Suite 1 Robo-advisors 1 Rust 1 SUSE 1 Snip. 1 Social Media 1 Software Engineering 1 Soli 1 Solo Projects 1 Solopreneurship 1 Sound 1 Sport 1 The Shack 1 Time Management 1 Tips 1 Tools 1 Tribler 1 U2 1 Ubuntu 1 WBC 1 Web browser 1 Windows 10 1 Windows errors 1 Work 1 World Cup 1 World Cup 2026 1 X-Files 1 X-files 1 ZenFone 1 a drop of motivation 1 ad blocking 1 addiction 1 aids 1 algorithms 1 animations 1 assertiveness 1 audio 1 automateit 1 autonomous cars 1 awareness 1 bash on windows 1 bat files 1 batch 1 battery 1 better life 1 better living 1 better quality 1 bin/bash 1 blocking 1 body language 1 bookmarks 1 boxing 1 brain 1 business intelligence 1 c# 1 campaign 1 cards 1 chemistry 1 clearance 1 clothing industry 1 cmd 1 code editor 1 coldplay 1 command history 1 command prompt 1 configuration management 1 console 1 conspiracy 1 conspiracy theories 1 converter 1 creativity 1 cyberattacks 1 date and time 1 deep learning 1 digital clothing 1 dreams 1 dubai 1 dying 1 e-book 1 economy 1 emotions 1 energy 1 evolution 1 exploitation 1 extreme 1 file sharing 1 file size 1 flat earth 1 flying 1 food 1 football 1 for sale 1 format change 1 free 1 free application 1 friend location 1 future of transport 1 future of work 1 genius 1 geoengineering 1 growing up 1 hacking 1 helion 1 history 1 hobby 1 hostname 1 hostnamectl 1 how many people live on earth 1 humor 1 immortality 1 innovation 1 interesting websites 1 interface 1 investing 1 javascript 1 kuba wojewódzki 1 labor market 1 light 1 login 1 machine learning 1 magic 1 make life harder 1 making money 1 meditation 1 messenger 1 mind programming 1 mindfulness 1 mounting 1 mp3 player 1 music 1 music player 1 mysteries 1 net use 1 network resources 1 new player 1 new things 1 onestep4red 1 opensource 1 parenting 1 parents 1 pdf 1 penetration testing 1 performance 1 personal data 1 philosophy 1 php 1 plague 1 player 1 poison 1 programming 1 promissory notes 1 prompt 1 protection 1 questions 1 radar 1 red 1 relax 1 relaxation 1 reportage 1 rest 1 robotaxi 1 science 1 scientific facts 1 screen 1 screenshot 1 show 1 skydive 1 smart clothing 1 social engineering 1 social media 1 society 1 software 1 space 1 sport 1 sports 1 stalking 1 statistics 1 sub-millimeter sensor 1 syngrapha 1 system acceleration 1 system administration 1 tablet 1 talk show 1 television 1 terrorism 1 testing 1 the world in numbers 1 threats 1 time travel 1 timelapse 1 tools 1 ubuntu 1 upbringing 1 users 1 weather 1 web browser 1 webmaster 1 windows automation 1 wisdom 1 work 1 world 1 world cup 2026 1 www 1 you are a miracle 1 youtube 1 zeitgeist 1

Blog archive

Table of contents