15

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?

1
  • 2
    This is just called prompt normally
    – xji
    Nov 7, 2016 at 20:47

2 Answers 2

25

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.

5
  • 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, 2016 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, 2016 at 5:05
  • @PeterMortensen PS prompts are POSIX.
    – heemayl
    Nov 6, 2016 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, 2016 at 14:36
  • @chepner Too much generalization from my side (on popular prompts) :/
    – heemayl
    Nov 6, 2016 at 14:40
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .