brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: hostnamectl set-hostname renames a linux machine the proper way

Linux
~/tips/tip-linux-hostnamectl-set-hostname

sudo hostnamectl set-hostname nas01

Changes the hostname of a systemd machine at once and keeps it after a reboot.

I stopped editing hostname files by hand because one command covers the lot.

sudo hostnamectl set-hostname nas01
hostnamectl

set-hostname writes /etc/hostname and changes the running hostname, so no reboot is needed. hostnamectl then shows the static hostname, machine ID, kernel and virtualization type. It does not touch /etc/hosts. If that file still maps 127.0.1.1 to the old name, update it yourself, or sudo may print a warning that it cannot resolve the new host.

Further reading: hostnamectl manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link