There are several ways by which we can change the hostname in linux. The process may vary based on distribution of linux.
To see your system current host name use,
# hostname
# cat /bin/hostname
On debian system you can use,
# uname -n
To see the fully qualified domain name if you have use,
#hostname –fqd
Temporary Change hostname
To change the hostname temporary issue,
#hostname new_name which will change your current hostname to the new_name. You will most probably need to exit the current shell in order to see the change in your shell prompt. However changes in this way is not persistent because if the system reboot it will show the hostname values from a particular field.
Permanently change hostname of Debian Linux
To change the hostname of debian linux distribution edit the file /etc/hostname as debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh
So, to change it in debian issue,
#vi /etc/hostname
and put a new entry there.
After changing to make it active run the script /etc/init.d/hostname.sh
# /etc/init.d/hostname.sh
Use sysctl to change the hostname both in RHL and debian
This process can be used both debian and red hat linux distribution. In this process use sysctl to change the variable kernel.hostname.
To read the current hostname issue,
#sysctl kernel.hostname
To change the current hostname to new_name issue,
#sysctl kernel.hostname=new_name
Change the hostname permanently in RHL Linux
This system is avilable for RHL distribution. Not apply for debian distribution. In this system change the network configuration file /etc/sysconfig/network in RHL.
Edit the /etc/sysconfig/network and change the hostname parameter to the new_name.
#vi /etc/sysconfig/network
HOSTNAME=new-host-name
Restart the network which relied on the hostname. You can perform reboot here.
# service network restart
Or,
#/etc/sysconfig/network-scripts/ifcfg-eth0
You may need to restart your console.
#init 3
#init 5
Related Documents
Vi Command in Unix.
Terminate Process on UNIX
umask and permission in unix.
How to change/configure IP Address on Linux/ Fedora /Ubuntu
Copy files between Unix and Windows with rcp
Screen -A very useful unix tool to work with remote system
Different ways to take Screenshot on Linux
Memory Usage of Solaris Operating System
No comments:
Post a Comment