10

Linux:
echo name > /etc/hostname

Windows:
This PC -> Properties -> Extended Settings -> Hostname -> OK.

The fuck windows?!
I'm changing a hostname, not taking out a loan.

Comments
  • 4
    Then you're wondering why your programs suddenly start reporting weird errors.

    Then you learn you have to update /etc/hosts too.
  • 0
    grep -rl $OLDHOSTNAME /etc | xargs sed -i "s/OLDHOSTNAME/$NEWHOSTNAME/g"
  • 0
    @stop
    Are you just being creative here, or do you imply, that there is a simpler way of changing the windows hostname, and I'm taking an unnecessary complex route?
    Because if there is a simpler way, I'd really like to know.
  • 1
    @metamourge the hostname is used in /etc/hostname /etc/hosts /etc/postfix/main.cf and other files. So instead of manual searching the hostname i use grep recursive (-r) and since i want the files i use -l (lower L).
  • 0
    @stop
    that is dangerous. use only when you know EXACTLY what is the risk here.

    In any case - the windows thing is wrong. there is a way to change the hostname from cli.
  • 5
    Windows:
    Rename-Computer -NewName "new host name"
  • 3
    hostnamectl. Use it.
  • 2
    You forgot the reboot requirement when changing your hostname on Windows.
Add Comment