Translation(s): English - Italiano

Rename a computer

This page explains how to change a system's hostname (i.e. rename a computer/server)

Executive summary: hostname(1) isn't enough.

Core networking

Application specific


Avahi is used to publish (announce) local services. If you tweaked /etc/avahi/* you should run:


CUPS is the Common Unix Printing System.

Adjust the /etc/printcap file.

You'll want to change the old hostname in any lines like this, hostname in bold: Kyocera_TASKalfa_3050ci|Kyocera TASKalfa 3050ci:rm=debian:rp=Kyocera_TASKalfa_3050ci: You'll need to restart the service for changes to take effect.


Refer to the Change Computer Hostname section of the ejabberd Installation and Operation Guide.


Reconfigure Exim (this adjusts /etc/exim4/update-exim4.conf.conf and /etc/mailname):

Or adjust manually /etc/exim4/update-exim4.conf.conf (hostname=). You need to restart the service.


Reconfigure Exim (see above) or adjust manually /etc/mailname. You don't need to restart the service.

Message Of The Day

Adjust /etc/motd. You don't need to restart a service.

OpenSSH server

Adjust /etc/ssh/, /etc/ssh/, /etc/ssh/ and /etc/ssh/ (root@hostname at the end). You need to restart the service.

Self-signed SSL certificate

Recreate the self-signed certificate created by the ssl-cert package using the hostname currently configured on your computer.

You need to restart the services using it, e.g. apache2.


Ssmtp is a light weight, send-only SMTP server.

Adjust /etc/ssmtp/ssmtp.conf (hostname=, etc.). You don't need to restart the service.


In order to make new hostname appear on syslog you should restart sysklogd service


fail2ban scan logs to detect connexion failures and can ban IP on too many failures.

The hostname may be in the sender mail address in /etc/fail2ban/jail.local. You need to reload the service.


Logical Volume Manager (LVM) is a device mapper target that provides logical volume management.

Hostname appears in the backup configuration file /etc/lvm/backup/<your Volume Group>.

Idea of script to help you on

Intrusive script

Please understand that this script is dangerous. You should check if all the files listed by grep -rl "$old" /etc must really be modified before launching this script:

   1 #!/bin/bash
   2 #
   3 usage() {
   4    echo "usage : $0 <new hostname>"
   5    exit 1
   6 }
   8 [ "$1" ] || usage
  10 old=$(hostname)
  11 new=$1
  13 grep "$old" /etc/ -rl 2>/dev/null |
  14 while read file
  15 do
  16       sed "s:$old:$new:g" "$file" > "$file.tmp"
  17       mv -f "$file.tmp" "$file"
  18 done

Take care you'd better do a grep before...

Not-so intrusive script

usage() {
   echo "usage : $0 <new hostname>"
   exit 1

[ "$1" ] || usage


for file in \
   /etc/exim4/update-exim4.conf.conf \
   /etc/printcap \
   /etc/hostname \
   /etc/hosts \
   /etc/ssh/ \
   /etc/ssh/ \
   /etc/motd \
   [ -f $file ] && sed -i.old -e "s:$old:$new:g" $file

See also