Hostname of ubuntu pc shown twice in terminal

Ubuntu Support Template

Ubuntu Version:
26.04

Desktop Environment (if applicable):
GNOME

Problem Description:

My Device name is: naresh-paul-memorial-trust-H310M-S2-2-0. This is correct one.

But when I’m opening the Terminal it shown as: naresh-paul-memorial-trust@naresh-paul-memorial-trust-H310M-S2-2-0:~$ .

How should I rectify it?

@anupammitra I edited your title to show normal case. Please do not use all caps, some may interpret this as being rude.

Additionally, the support template is there for a reason. To help you provide us with as much information as possible.

Why? So the volunteers here can give you better support.

Please go back and edit your post. Enter the information that is needed for your support request.

Whatever you do not need or is irrelevant can simply be removed before you save the post.

Thanks

2 Likes

The terminal format for user and device is
username@device

From the information provided:-
naresh-paul-memorial-trust is your user name
naresh-paul-memorial-trust-H310M-S2-2-0 is your device name

Gnome settings > System > Users (to add and remove accounts)
Gnome settings > System > About (to change device name)

2 Likes

This would be correct. For example the name I chose is norm and when I open a terminal this what I see:

norm@norm-Latitude-E7450

Below is indeed your device name

But this is your USER name:

In terminal as far back as I can remember it always shows as user@device name.

2 Likes

Assuming you’re using bash as your default shell, edit ~/.bashrc and look for the lines that defines $PS1.

You should see something like this:

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

The “\u” and “\h” are shortcuts for username and host. You can set those values something explicit like naresh@mymachine or whatever.

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]naresh@mymachine\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Save the file and exit the terminal. Next time you start the terminal it should reflect your changes.

Note that this does not change your username or the hostname to the device, they’ll remain the same. It’s just the shell prompt that’s being changed.

1 Like

Agreed, but this is unusual to me. Because, in my personal PC it looks as anupam@anupam-pc:~$. The only difference is in my personal PC the Ubuntu version is 24.04.

Thanks for your care and support.

So far I can recollect this was not so when this PC was running under Ubuntu 24.04.

However, thanks for your care.

Thanks for your cooperation and support.

The PC in question with Ubuntu 26.04 is not your PC?

The terminal format is the same for both Ubuntu 24.04 and Ubuntu 26.04
username@device

3 Likes

You can make the terminal say what you like. There’s even a slot machine style game that plays in the PS1 variable. Can even have the system time printed. It’s super customisable

Whilst that maybe true (I don’t know of a ‘slot machine style game’ but would have no interest in it), but yes the prompt $PS1 is super customizable, but is that helpful to the Original Poster?

The duplication is possibly $HOSTNAME & $USERNAME having identical values and the OP isn’t recognizing that fact. What its also capable of doing is really ‘besides the point’ of this help request (in my view).

1 Like

Poster may not be aware of the flexibility and then decide to want a different value for the variable. It’s a chance for education rather than simply solving an issue.

1 Like

In true sense the PC (Ubuntu 26.04) in question is not my personal. This is being used and maintained by me in an office of volunteers of social work.

So…what exactly do you want from us in this topic?

Are you the admin, do you have sudo rights to the computer?

Others have already explained the username@device format so it is not clear to me what your goal is at this point in time.

Please help us understand.

2 Likes

I give reply in seriatim.

I raised the topic and asked for help/suggestions from the experts. All of them have clarified the position.

Yes, I’m the Admin and have sudo rights to the computer.

Do you think I’ve argued unnecessarily about the advice of experts? Why are you so intolerant?

I’m not sure what you think is intolerant about us wondering what the goal of your question was originally (It isn’t really clear if you are asking for any help here or just want an explanation of the status quo) …

You seem to be logged in as the user naresh-paul-memorial-trust to a machine named naresh-paul-memorial-trust-H310M-S2-2-0 if you want to change either of these values you can:

  • create a different user with a different name and log in as that
  • change the hostname of the machine using the sudo hostnamectl set-hostname <new hostname>
3 Likes

Or change his PS1 prompt. Why go through the work of moving all your data from one user account to another, just to change the how the username@hostname appear in a terminal prompt? That’s overkill.

1 Like

How would you get a different user name with that ? :slight_smile:

(I mean. sure, you could script or hard-code something but would effectively never reflect reality in the end)

1 Like

OP didn’t say he wanted a different username. I assumed that this was a system belonging to an organization, and that the username might even be an autologin account. Since OP only mentioned the issue with the terminal, I also assumed the issue was the length and unwieldiness of of the prompt.

1 Like

See … and I assumed it was the duplication of the naresh-paul-memorial-trust :wink:

We should let the OP clarify what they actually want :slight_smile: