Hostname

Da PNLUG.
Versione del 29 set 2015 alle 18:41 di Rcolonello (Discussione | contributi) (Creata pagina con "=Questo piccolo script rendere facile ed interattivo il cambio del hostname= ==Debian Like== #!/bin/bash #Assign existing hostname to $hostn hostn=$(cat /etc/hostname)...")

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Questo piccolo script rendere facile ed interattivo il cambio del hostname

Debian Like

#!/bin/bash
#Assign existing hostname to $hostn
hostn=$(cat /etc/hostname)
#Display existing hostname
echo "Existing hostname is $hostn"
#Ask for new hostname $newhost
echo "Enter new hostname: "
read newhost
#change hostname in /etc/hosts & /etc/hostname
sed -i "s/$hostn/$newhost/g" /etc/hosts
sed -i "s/$hostn/$newhost/g" /etc/hostname
#display new hostname
echo "Your new hostname is $newhost"