Hostname: differenze tra le versioni

Da PNLUG.
(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)...")
 
(Debian Like)
Riga 4: Riga 4:
 
   
 
   
 
  #!/bin/bash
 
  #!/bin/bash
 
 
  #Assign existing hostname to $hostn
 
  #Assign existing hostname to $hostn
 
  hostn=$(cat /etc/hostname)
 
  hostn=$(cat /etc/hostname)
 
 
  #Display existing hostname
 
  #Display existing hostname
 
  echo "Existing hostname is $hostn"
 
  echo "Existing hostname is $hostn"
 
 
  #Ask for new hostname $newhost
 
  #Ask for new hostname $newhost
 
  echo "Enter new hostname: "
 
  echo "Enter new hostname: "
 
  read newhost
 
  read newhost
 
 
  #change hostname in /etc/hosts & /etc/hostname
 
  #change hostname in /etc/hosts & /etc/hostname
 
  sed -i "s/$hostn/$newhost/g" /etc/hosts
 
  sed -i "s/$hostn/$newhost/g" /etc/hosts
 
  sed -i "s/$hostn/$newhost/g" /etc/hostname
 
  sed -i "s/$hostn/$newhost/g" /etc/hostname
 
 
  #display new hostname
 
  #display new hostname
 
  echo "Your new hostname is $newhost"
 
  echo "Your new hostname is $newhost"

Versione delle 18:41, 29 set 2015

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"