Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: Gentoo User <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] Why is PS1 (the console prompt) different for the root user?
Date: Sat, 10 Jun 2017 19:06:40
Message-Id: 99104f79-1f40-4d2c-7be9-6de270be1deb@gmail.com
In Reply to: [gentoo-user] Why is PS1 (the console prompt) different for the root user? by Nikos Chantziaras
1 Nikos Chantziaras wrote:
2 > I noticed that the root prompt does not include the full path of the
3 > current directory. Normal user:
4 >
5 > me@gentoopc ~ $ cd /usr/bin
6 > me@gentoopc /usr/bin $
7 >
8 > However, for root:
9 >
10 > gentoopc ~ # cd /usr/bin
11 > gentoopc bin #
12 >
13 > So for users, I can see where I am ("/usr/bin"). For root, I cannot.
14 > It just says "bin".
15 >
16 > Now, I can change it easily in /etc/bash/bashrc (not sure if that's
17 > the correct place, but it works) by replacing "\W" with "\w". However,
18 > I'm curious as to why "\W" is used for root. When I have several root
19 > logins open (and I usually have to,) it makes it difficult to tell
20 > where I am. It says "bin", but am I in /usr/bin, /usr/local/bin,
21 > somewhere else?
22 >
23 > Is there a rationale for this?
24 >
25 >
26 >
27
28 It's been a while but if I recall correctly, it's so that you can tell
29 the difference when you are logged in as root or a user. While a user
30 can do some damage, root can cause all sorts of havoc. On mine, so that
31 even a idiot can tell what user I'm logged in as, which includes the
32 current person sitting in my chair, mine says root@fireball and is in
33 red then shows the path as well. When I am logged in as a user, it says
34 <username>@fireball and then the path and is in green. If it is red, be
35 careful. If it is green, well, can't generally harm the OS itself, can
36 cause havoc for that user tho. So, it's so that you can tell when you
37 are a user or root easily. Of course, you could set them both to the
38 same and hope for the best. ;-)
39
40 I don't know if it still does but the install guide used to have a line
41 to set it to chroot <something> to indicate that it is a chroot. When
42 switching around a lot, that can come in handy. I got curious. It's
43 still there:
44
45 |export PS1="(chroot) $PS1"
46
47 Basically, it is set to help the person in the chair distinguish what is
48 root and what is not.
49
50 Dale
51
52 :-) :-)
53 |