0

Can someone tell me if this is normal for the $ to move around or not?

While using Ubuntu 16.04 command line the $ is at the directory name as it should be. However, when I change to any directory the $ then becomes part of the directory name at the end part of the directory name. How do I correct this new problem?

This is the root directory position -- hallgroup@oldoffice:~$

This is the position when I CD to any location -- hallgroup@oldoffice:/usr$

I just do not remember this being like this before. How do I correct this?

dlin
  • 3,900

2 Answers2

1

The problem is: What does that line mean? Each of its component is significative. In fact, that line can be read as

UserName@HostName:FolderInHost$

The meaning of the symbol $ and its other possible values are explained here. Please have a careful read there.

Note also that ~ is not root, but it is just a shortcut for your home directory /home/hallgroup. This, as well as the $ above, comes from Unix and it is the same in a lot of Unix-based environment (so MacOS too, for example).

The root is /, and it is not the home of any user.

If you cd / you will see that the folder part of the line changes to /.

With this in mind, it is clear that hallgroup@oldoffice:~$ and hallgroup@oldoffice:/usr$ are exactly the same thing, just telling you that you are in /home/hallgroup and in /usr respectively.

dadexix86
  • 6,776
0

As user535733 told you, it is the default view, but you can customize it modifying the file in ~/.bashrc.

In that file there is a line that is more or less like this:

PS1='${debian_chroot:+($debian_chroot)}\[\e[01;32m\]\u@\h\[\e[00m\]:\[\e[01;34m\]\w\[\e[00m\] \$ '

To cut a long story short, it is telling you:

  • write in bold green color (that is the escape code \e[01;32m\]) the username followed by a @ and then by the host name (\u@\h)
  • put a double comma, then the current directory (in blue)
  • at the end, put a dollar sign

If you change the line in the following way:

PS1='${debian_chroot:+($debian_chroot)}\[\e[01;32m\]\u@\h\[\e[00m\]: \$ \[\e[01;34m\]\w\[\e[00m\] '

you have moved the dollar sign. You can customize the string as you want, also adding time and date or a welcome message. As soon as you save the file (backup it before modification) perform the command:

source ~/.bashrc 
Lorenz Keel
  • 9,511