[Solved] How do you change computer's name?

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
RamBurner
Level 4
Level 4
Posts: 385
Joined: Wed Nov 23, 2011 7:31 pm

[Solved] How do you change computer's name?

Post by RamBurner »

I neglected to change the computer's name during install, how do I change it? I'm not seeing where to do that.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

To find out your computer name, in a terminal either hostname or hostnamectl which gives you a bit more info.

To change your hostname in a terminal hostnamectl set-hostname 'newname'. Then verify it has changed by using one of the first commands again.

It helps to keep hostnames short.

Code: Select all

andy@T432 ~ $ hostnamectl
   Static hostname: T432
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 4095cb9d62054733b651d895c996ea84
           Boot ID: 954a8515183842cbafb05c3209afc068
  Operating System: Linux Mint 19
            Kernel: Linux 4.15.0-99-generic
      Architecture: x86-64
andy@T432 ~ $ hostname
T432
andy@T432 ~ $ hostnamectl set-hostname 'T433'
andy@T432 ~ $ hostname
T433
andy@T432 ~ $ hostnamectl set-hostname 'T432'
andy@T432 ~ $ hostname
T432
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
RamBurner
Level 4
Level 4
Posts: 385
Joined: Wed Nov 23, 2011 7:31 pm

Re: How do you change computer's name?

Post by RamBurner »

Thank you very much. This is the first time in about 500 installs I didn't change it, oops. :lol:
User avatar
AZgl1800
Level 20
Level 20
Posts: 11175
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: How do you change computer's name?

Post by AZgl1800 »

double thanks.....
my laptop's name was about 25 characters.... hated it.
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

AZgl1500 wrote: Tue May 05, 2020 9:19 pm double thanks.....
my laptop's name was about 25 characters.... hated it.
Made that mistake when I first started and then tried to network to another PC, hostname > 15 chars which was a netbios limitation. Don't know if that is still a problem today, anyway, altair4 helped me out. :)
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Moonstone Man
Level 16
Level 16
Posts: 6054
Joined: Mon Aug 27, 2012 10:17 pm

Re: How do you change computer's name?

Post by Moonstone Man »

AndyMH wrote: Wed May 06, 2020 4:33 am ... altair4 helped me out. :)
I thought it was a very elegant solution. I'll use that method in future. I was relying on editing /etc/hosts and /etc/hostname, followed by the obligatory reboot.
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

Kadaitcha Man wrote: Wed May 06, 2020 4:39 am I thought it was a very elegant solution.
I take no credit, found it on the web :)
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1374
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: How do you change computer's name?

Post by ricardogroetaers »

RamBurner wrote: Tue May 05, 2020 5:47 pm ..... to change the computer's name ..... , how do I change it? I'm not seeing where to do that.
Through the Xfce graphical interface:
Whisker menu -> System -> network.
In Mate and Cinnamon environments there must be something similar.

Click on the "Unlock" button and change the "machine name".
Image

Go to the "machines" tab and see if the machine's "nickname" has also changed.
Image

If necessary, change. Click on the "properties" button for that.

Note:
-The graphics features of Linux Mint are to be used and not confined in the "closet".
-the "network" program can be invoked by the Xfce terminal by typing the command:
network-admin
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

In Mate and Cinnamon environments there must be something similar.
Not in cinnamon, or I can't find it.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1374
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: How do you change computer's name?

Post by ricardogroetaers »

AndyMH wrote: Wed May 06, 2020 5:53 am Not in cinnamon, or I can't find it.
Try typing the command in a terminal window:
network-admin
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

ricardogroetaers wrote: Wed May 06, 2020 6:12 am Try typing the command in a terminal window:
network-admin
Worked, but not installed by default, at least in LM19.0, so had to install it first.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
jp14
Level 3
Level 3
Posts: 163
Joined: Wed May 01, 2019 4:47 pm
Location: Zud-Afrika

Re: How do you change computer's name?

Post by jp14 »

AndyMH wrote: Tue May 05, 2020 6:09 pm To find out your computer name, in a terminal either hostname or hostnamectl which gives you a bit more info.

To change your hostname in a terminal hostnamectl set-hostname 'newname'. Then verify it has changed by using one of the first commands again.

It helps to keep hostnames short.

Code: Select all

andy@T432 ~ $ hostnamectl
   Static hostname: T432
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 4095cb9d62054733b651d895c996ea84
           Boot ID: 954a8515183842cbafb05c3209afc068
  Operating System: Linux Mint 19
            Kernel: Linux 4.15.0-99-generic
      Architecture: x86-64
andy@T432 ~ $ hostname
T432
andy@T432 ~ $ hostnamectl set-hostname 'T433'
andy@T432 ~ $ hostname
T433
andy@T432 ~ $ hostnamectl set-hostname 'T432'
andy@T432 ~ $ hostname
T432
i did that and the name changed , but now i have this bash line on top every time i open terminal.
how to get rid of that?
Image
LM 19.3 Xfce


Cause I like things neat and simple
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

but now i have this bash line on top every time i open terminal
Reboot? Didn't have that problem because in my example, having changed the hostname I changed it back to what it was originally.

Edit - just checked, don't have that script, but do have a vte-2.91.sh in /etc/profile.d. It seems to manipulate the PS1 environment variable:
https://www.tecmint.com/customize-bash- ... mpt-linux/
Beyond that, have no idea what its purpose is.
Last edited by AndyMH on Wed May 06, 2020 10:26 am, edited 1 time in total.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
jp14
Level 3
Level 3
Posts: 163
Joined: Wed May 01, 2019 4:47 pm
Location: Zud-Afrika

Re: How do you change computer's name?

Post by jp14 »

Yes I did try reboot, still the same.
LM 19.3 Xfce


Cause I like things neat and simple
User avatar
AndyMH
Level 21
Level 21
Posts: 13736
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How do you change computer's name?

Post by AndyMH »

This is the content of vte-2.91.sh:

Code: Select all

# Copyright © 2006 Shaun McCance <shaunm@gnome.org>
# Copyright © 2013 Peter De Wachter <pdewacht@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Not bash or zsh?
[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0

# Not an interactive shell?
[[ $- == *i* ]] || return 0

# Not running under vte?
[ "${VTE_VERSION:-0}" -ge 3405 ] || return 0

__vte_urlencode() (
  # This is important to make sure string manipulation is handled
  # byte-by-byte.
  LC_ALL=C
  str="$1"
  while [ -n "$str" ]; do
    safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
    printf "%s" "$safe"
    str="${str#"$safe"}"
    if [ -n "$str" ]; then
      printf "%%%02X" "'$str"
      str="${str#?}"
    fi
  done
)

# Print a warning so that anyone who's added this manually to his PS1 can adapt.
# The function will be removed in a later version.
__vte_ps1() {
  echo -n "(__vte_ps1 is obsolete)"
}

__vte_osc7 () {
  printf "\033]7;file://%s%s\007" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
}

__vte_prompt_command() {
  local pwd='~'
  [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
  printf "\033]0;%s@%s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
}

case "$TERM" in
  xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
    [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
    ;;
esac

true
you might try creating it as the missing script vte.sh and see what happens.
EDIT - owner is root and it is executable, so you will need to change properties.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
jp14
Level 3
Level 3
Posts: 163
Joined: Wed May 01, 2019 4:47 pm
Location: Zud-Afrika

Re: How do you change computer's name?

Post by jp14 »

ok thanks , but found this solution that fixed it .
earlier i installed the budgie DE ,didn't like it so uninstalled again.
seems that created that problem

Image
LM 19.3 Xfce


Cause I like things neat and simple
User avatar
paddys-hill
Level 1
Level 1
Posts: 33
Joined: Mon Jun 14, 2021 5:07 pm
Location: All over the Adelaide Hills and Fleurio region of South Australia

Re: [Solved] How do you change computer's name?

Post by paddys-hill »

(Knock, knock Sorry to disturb you folks but it looks like a knowledgable enough group for this)

Where can I set up the domainname for a server and how do I make it persist?

tia
Paddys-Hill Co-op co-ordinator & sysadmin
Acer Aspire A315-21G (AMD A9-9420 RADEON R5) running 5.11.0-22-generic
Distro: Linux Mint 20.1 Ulyssa DE:Cinnamon 4.8.6 WM: muffin 4.8.1 DM: LightDM 1.30.0
User avatar
jodarove
Level 1
Level 1
Posts: 41
Joined: Wed Feb 19, 2020 12:16 pm

Re: How do you change computer's name?

Post by jodarove »

AndyMH wrote: Tue May 05, 2020 6:09 pm To find out your computer name, in a terminal either hostname or hostnamectl which gives you a bit more info.

To change your hostname in a terminal hostnamectl set-hostname 'newname'. Then verify it has changed by using one of the first commands again.

It helps to keep hostnames short.

Code: Select all

andy@T432 ~ $ hostnamectl
   Static hostname: T432
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 4095cb9d62054733b651d895c996ea84
           Boot ID: 954a8515183842cbafb05c3209afc068
  Operating System: Linux Mint 19
            Kernel: Linux 4.15.0-99-generic
      Architecture: x86-64
andy@T432 ~ $ hostname
T432
andy@T432 ~ $ hostnamectl set-hostname 'T433'
andy@T432 ~ $ hostname
T433
andy@T432 ~ $ hostnamectl set-hostname 'T432'
andy@T432 ~ $ hostname
T432
Thank you!!! worked perfectly!
I'm here to learn!
mikeflan
Level 17
Level 17
Posts: 7130
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: [Solved] How do you change computer's name?

Post by mikeflan »

i did that and the name changed , but now i have this bash line on top every time i open terminal.
how to get rid of that?
This is a temporary fix. Type this in the terminal:

Code: Select all

PS1=$
PROMPT_COMMAND=
echo -en "\033]0;my_new_name\a"
Locked

Return to “Other topics”