Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy

 Some examples

In order to understand these prompts and the escape sequences used, we refer to the Bash Info or man pages.

  • export PS1="[\t \j] "

    Displays time of day and number of running jobs

  • export PS1="[\d][\u@\h \w] : "

    Displays date, user name, host name and current working directory. Note that \W displays only base names of the present working directory.

  • export PS1="{\!} "

    Displays history number for each command.

  • export PS1="\[\033[1;35m\]\u@\h\[\033[0m\] "

    Displays user@host in pink.

  • export PS1="\[\033[1;35m\]\u\[\033[0m\] \[\033[1;34m\]\w\[\033[0m\] "

    Sets the user name in pink and the present working directory in blue.

  • export PS1="\[\033[1;44m\]$USER is in \w\[\033[0m\] "

    Prompt for people who have difficulties seeing the difference between the prompt and what they type.

  • export PS1="\[\033[4;34m\]\u@\h \w \[\033[0m\]"

    Underlined prompt.

  • export PS1="\[\033[7;34m\]\u@\h \w \[\033[0m\] "

    White characters on a blue background.

  • export PS1="\[\033[3;35m\]\u@\h \w \[\033[0m\]\a"

    Pink prompt in a lighter font that alerts you when your commands have finished.

  • export PS1=...

Variables are exported so the subsequently executed commands will also know about the environment. The prompt configuration line that you want is best put in your shell configuration file, ~/.bashrc.

If you want, prompts can execute shell scripts and behave different under different conditions. You can even have the prompt play a tune every time you issue a command, although this gets boring pretty soon. More information can be found in the Bash-Prompt HOWTO.

Introducing Linux
Previous Page Home Next Page

  Published under the terms of the GNU General Public License Design by Interspire