Using hostnamectl to Change the Hostname
-
Open a Terminal: Launch a terminal in your Manjaro system.
-
Change the Hostname: Use the
hostnamectlcommand to set the new hostname:sudo hostnamectl set-hostname new-hostnameReplace
new-hostnamewith the desired hostname. -
Verify the Change: To confirm the new hostname has been set, run:
hostnamectlThis will display the current hostname along with other system information.
-
Edit
/etc/hosts(Optional but Recommended):- You should still update the
/etc/hostsfile to ensure proper hostname resolution. Open the file with:sudo nano /etc/hosts - Update the line containing the old hostname to the new one:
127.0.1.1 new-hostname - Save and exit.
- You should still update the
-
Reboot the System (Optional): While the hostname change takes effect immediately for many operations, a reboot ensures all services recognize the new hostname:
sudo reboot
This method is straightforward and effectively changes the hostname system-wide.