Alpine Linux Change Hostname (computer name)
In Alpine Linux, you can change the hostname (computer name) by following these steps:
- First, open the system's hostname configuration file, typically located at
/etc/hostname, by running the following command:
nano /etc/hostname- Replace the current hostname with your desired hostname in the file, then save and close the file.
- Next, you should also update the hostname in the system's hosts file located at
/etc/hosts, by running the following command:
nano /etc/hostsIn the file, change the name at the first line after 127.0.0.1, with your new hostname.
- Now, you need to tell the running system to update the hostname by running the following command:
hostname -F /etc/hostname- Finally, restart the networking service to apply the changes:
rc-service networking restart- You can also use the
hostnamecommand to check the current hostname, for examplehostname.
Also, note that some applications may have hardcoded the old hostname, and will not work until they are updated or reconfigured.
