110 words
1 minutes
Prompt Description
2025-04-16

Prompt Description#

Understanding and Customizing the Bash Prompt#

  • The Bash prompt appears when the system is ready for a command.
  • By default, it shows:
<username>@<hostname>:<current directory>$

Example: user@kali:~$

~ refers to the home directory

$ indicates a regular user

# indicates root user

PS1 Variable – Controls Prompt Appearance#

  • The PS1 variable defines how the prompt looks.
  • When not set properly, the prompt may show only $ or # without extra info.

Useful PS1 Special Characters#

SymbolDescription
\\uUsername
\\hHostname (short)
\\HHostname (full)
\\wCurrent working directory (full path)
\\dDate (e.g., Mon Feb 6)
\\D{%Y-%m-%d}Custom date format (e.g., 2025-04-16)
\\tCurrent time (24-hour)
\\TCurrent time (12-hour)
\\@Time (AM/PM)
\\sShell name
\\nNew line
\\rCarriage return

Why Customize the Prompt?#

  • Adds useful info (e.g., time, path, IP).
  • Helps in pentesting and troubleshooting.
  • Can be made colorful and clean using .bashrc, bash-prompt-generator, or Powerline.
Prompt Description
https://fuwari.vercel.app/posts/prompt-description/
Author
Yonten
Published at
2025-04-16