Score:0

Ubuntu Studio 22.04.1 LTS Terminal commands not changing hostname

bh flag

When I set up my new install I typed in my username and didn't change the suggested hostname so it's currently 'user-hostname' so when I type in Terminal it shows as "user@user-hostname" and I'd like it to be just 'hostname' so "user@hostname"

I can't find a setting in the GUI and I've tried two different Terminal commands

sudo hostnamectl set-hostname

and

sudo hostname

I don't know why it's not working...

Thanks in advance!

Update: I must have missed it after my last reboot but it appears to have worked, Thanks for the assistance!

stdunbar avatar
aq flag
Have you rebooted after running `hostnamectl`? If so, can you share what name you used? There are some restrictions on the hostname.
TriumphantToil avatar
bh flag
I haven't rebooted, I'll try that and get back to you. The hostname is 'workhorse', I'm not changing the hostname, just wanted to remove my username and hyphen from in front of it.
stdunbar avatar
aq flag
I misunderstood. That is set in your `.bashrc`. Look for `PS1`.
TriumphantToil avatar
bh flag
Sorry for the late reply, I've rebooted it and it maintains the original hostname. I'll check out .bashrc and PS1 (sounds like my childhood lol)
TriumphantToil avatar
bh flag
It appears that rebooting did indeed resolve the issue, I can't see a way to upvote your comment or mark my question as solved. I feel like such a noob haha.
Score:0
ao flag

on my server,i do this:

vim ~/.bashrc +59

  • \u: username

  • \h: user-hostname

change the PS1

after the change,ensure file effective:

source ~/.bashrc

and, it worked

  • before :

user@user-hostname

  • after:

only user-hostname

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.