Terminal prompt: how to change the displayed name of the home folder on Gnome Terminal

Asked by gabriell nascimento

The Summary is not so clear, but my doubt is pretty simple: My Gnome Terminal is showing "user@hostname: /home/user/$ " instead of "user@hostname: ~/$ ".
I just want to know how I can change it back.

Thanks.
Até mais.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
Last query:
Last reply:
Revision history for this message
delance (olivier-delance) said :
#1

You must set in .bashrc the value of PS1 variable to change such prompt.
But I presume you can't replace full pathname by this shortcut.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

if you run:

cd

Does it change?

Revision history for this message
gabriell nascimento (gabriellhrn) said :
#3

delance:

I have a desktop running Oneiric and there I don't have that problem, but the PS1 variable has the same value in both desktop (with no problems) and my notebook (with the problem I said).
I'm pretty sure I've changed a file and got the problem, but I can't remember which file was that. :-|

actionparsnip:

No, it doesn't. Doesn't matter the cd command I do, it keeps the same thing...

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#4

user@hostname:/home/user/$ and user@hostname:~/$ are both very strange prompts. Are you sure it's not currently user@hostname:/home/user$ and user@hostname:~$ ?

Revision history for this message
gabriell nascimento (gabriellhrn) said :
#5

Kagan:

You're right. I put an extra "/". (Oops)

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#6

On the affected computer (the one that won't display ~), what is the output of:

echo ~

Also, what is the output of:

echo $HOME

Also, what is the output of:

echo $USER

Also, what is the output of:

echo ~$USER

If possible, it would be best for you to select the entire block of text in which you run these commands and see their output, starting with the beginning of the line on which you enter the first command, and including all the prompts. This will reveal your actual hostname and username, but it would be preferable for you to do so if you do not consider it unacceptable information disclosure, since maybe there is something about at least your username that is triggering this condition (even if it is the same username as on your other computer that doesn't have the problem).

Revision history for this message
gabriell nascimento (gabriellhrn) said :
#7

output:

gabriellhrn@Vulcan:/home/gabriellhrn$ echo ~
/home/gabriellhrn/
gabriellhrn@Vulcan:/home/gabriellhrn$ echo $HOME
/home/gabriellhrn/
gabriellhrn@Vulcan:/home/gabriellhrn$ echo $USER
gabriellhrn
gabriellhrn@Vulcan:/home/gabriellhrn$ echo ~$USER
~gabriellhrn
gabriellhrn@Vulcan:/home/gabriellhrn$

--
There you are. Plus, the usernames are different on the computers.

Revision history for this message
Best Eliah Kagan (degeneracypressure) said :
#8

It's strange that there are trailing slashes in the expansions of ~ and $HOME. I am guessing that this is the cause of the problem. A ~ is shown if the present working directory path contains it, but it doesn't contain the final slash. If a subdirectory (let's say it's called foo) of your home directory displays as "~/foo" when you cd to it, that would pretty well confirm this hypothesis. What happens when you cd to a subdirectory of your home directory?

Also, what's the output of this command?

grep gabriellhrn /etc/passwd

(The file /etc/passwd does not actually contain the password hashes of any user. Those are in /etc/shadow, which is readable only by root and should *not* be posted publicly, as the hashes can be cracked.)

If that shows your home directory as ending with a slash, then you can simply change your home directory path to remove the leading slash, and it should fix this problem. One way to do that is to run:

sudo usermod -d /home/gabriellhrn gabriellhrn

(Make sure to spell it correctly.)

If the above instructions enable you to solve the problem, then there's no need for you to post the output of anything. In that case, you can just mark this question as Solved.

Revision history for this message
gabriell nascimento (gabriellhrn) said :
#9

You were right again! That solved my problem. Now I remember how I got the problem: I made a mess with my users and the /home that was on another partition.

Thank you very much.

Revision history for this message
gabriell nascimento (gabriellhrn) said :
#10

Thanks Eliah Kagan, that solved my question.