Create and assign a random hostname to a Linux system every time it boots up.
- Clone the repository and navigate to its directory.
git clone https://github.com/ryanmroth/randomhost.git
cd randomhost
- Copy the "randomhost" file to the "/usr/bin/" directory or any other location that is included in your $PATH variable:
sudo cp randomhost /usr/bin
Note: If copying "randomhost" to a location other than "/usr/bin", edit line 7 in "randomhost.service" accordingly:
- ExecStart=/usr/bin/randomhost + ExecStart=/your/directory/randomhost
- Set the executable permission for the copied "randomhost" file:
sudo chmod +x /usr/bin/randomhost
- Copy the "randomhost.service" file to the "/etc/systemd/system/" directory:
sudo cp randomhost.service /etc/systemd/system
- Ensure the permissions of the "randomhost.service" file are 644:
sudo chmod 644 /etc/systemd/system/randomhost.service
- Refresh the systemd systemctl daemon by executing:
sudo systemctl daemon-reload
- Enable the service by running:
sudo systemctl enable randomhost
Before depending on the boot process, you can manually initiate the service to verify that it operates as intended.
- Start the service by executing:
sudo systemctl start randomhost
- Verify the hostname has been changed by running:
hostname
- Examine the changes to the "/etc/hosts" file:
cat /etc/hosts