Skip to content

Generate and set a random hostname on Linux boot

Notifications You must be signed in to change notification settings

ryanmroth/randomhost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Random Host

Create and assign a random hostname to a Linux system every time it boots up.

Installation

  1. Clone the repository and navigate to its directory.
  git clone https://github.com/ryanmroth/randomhost.git 
  cd randomhost
  1. 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
  1. Set the executable permission for the copied "randomhost" file:
sudo chmod +x /usr/bin/randomhost
  1. Copy the "randomhost.service" file to the "/etc/systemd/system/" directory:
sudo cp randomhost.service /etc/systemd/system
  1. Ensure the permissions of the "randomhost.service" file are 644:
sudo chmod 644 /etc/systemd/system/randomhost.service
  1. Refresh the systemd systemctl daemon by executing:
sudo systemctl daemon-reload 
  1. Enable the service by running:
sudo systemctl enable randomhost

Optional

Before depending on the boot process, you can manually initiate the service to verify that it operates as intended.

  1. Start the service by executing:
sudo systemctl start randomhost
  1. Verify the hostname has been changed by running:
hostname
  1. Examine the changes to the "/etc/hosts" file:
cat /etc/hosts

About

Generate and set a random hostname on Linux boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages