Linux Mint 21.3: Command Line; Setting hostname as is With Installer
by des_a from LinuxQuestions.org on (#6Q1PW)
This is a small question, that's been bugging me for a bit. In Linux Mint, you can set a hostname on install of the distro. But I cannot find a tool after that for setting the hostname, plus I would like to do it from the bash shell. It needs to start with being exactly equivalent to setting it there, and branch off from there. I'm not sure if my code correctly does that or not. Please teach me.
Code so far:
Code:#! /bin/bash
set $hostv = ""
read -p "Hostname? " hostv
set $domainv = ""
read -p "Domainname? " domainv
echo setting hostname to \"$hostv\"...
sudo hostnamectl set-hostname $hostv.$domainv
sudo cp -f /etc/hostname /etc/hostname.old
sudo echo $hostv.$domainv > /etc/hostname
sudo hostnamectl status
sudo echo $hostv > /etc/settings/hostname.cfg
sudo echo $domainv > /etc/settings/domainname.cfg
Code so far:
Code:#! /bin/bash
set $hostv = ""
read -p "Hostname? " hostv
set $domainv = ""
read -p "Domainname? " domainv
echo setting hostname to \"$hostv\"...
sudo hostnamectl set-hostname $hostv.$domainv
sudo cp -f /etc/hostname /etc/hostname.old
sudo echo $hostv.$domainv > /etc/hostname
sudo hostnamectl status
sudo echo $hostv > /etc/settings/hostname.cfg
sudo echo $domainv > /etc/settings/domainname.cfg