I was wondering if there is any name to the leftmost text (after which we type the command) in a Linux terminal.

Like

ubuntu@Ubuntu:~$ 

Do we have a name for this?

  • 2
    This is just called prompt normally – xji Nov 7 '16 at 20:47
up vote 25 down vote accepted

It's called the primary prompt string, set by the shell according to the PS1 environment variable. This is usually set per user basis, for interactive shells only, (usually) defined in ~/.bashrc with the default as \s-\v\$.

On my system:

$ echo "$PS1"
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\W\$ 

and expanded to:

username@hostname:pwd$ 

Check the PROMPTING section of man bash to see what each token does.

  • 1
    When someone answers me with this quality, I usually wonder how long will it take for me to be at your depth of knowledge. Thanks :-) – Nabin Nov 6 '16 at 4:54
  • 3
    @NabinKhadka Thank you for your kind comments. I am an absolute amateur, still learning every day from the smarter people around me. Everybody was a beginner at some stage, so keep learning and best wishes!! – heemayl Nov 6 '16 at 5:05
  • Assuming Bash is the shell, etc.? – Peter Mortensen Nov 6 '16 at 10:12
  • @PeterMortensen PS prompts are POSIX. – heemayl Nov 6 '16 at 10:55
  • PS1, PS2, and PS4 are POSIX. PS3 is used by the non-POSIX select command, and bash recently introduced a PS0 prompt to display after reading a command but before actually executing it. – chepner Nov 6 '16 at 14:36

The prompt. There are ways of editing what it shows, e.g. see here. Most of these personalizations can be used with other shells e.g. ZSH, or KSH. TCSH may act a little differently, but I am less familiar with it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.