Solved

Linux RedHat5 - Change hostname of the machine

Posted on 2013-01-18
6
321 Views
Last Modified: 2013-01-20
Hi,

I have a redhat 5 installation and I want to change the hostname of it..

This is the name now:
[root@localhost ~]# hostname
localhost.localdomain

I will edit this file:
/etc/sysconfig/network


But do I need to restart the mahcine to have changed?

Tks,
Joao
0
Comment
Question by:joaotelles
  • 3
  • 2
6 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 38793484
You should change as you said in the file /etc/sysconfig/network the following
NETWORKING=yes
HOSTNAME=myhost.example.com


Also
Issue command

hostname myhost.example.com

Then it will take into effect without reboot. Next time when it reboots, it will pick it up from the above file
0
 
LVL 8

Expert Comment

by:R_Edwards
ID: 38793485
or you can just

sudo hostname new.hostname
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38793491
Yes, with above commands I presumed that you will already be root user.

Furthermore, you have to do combination of both because without this it will not persist after reboot.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 8

Expert Comment

by:R_Edwards
ID: 38793543
Farzanj, you are correct on the reboot not keeping the name..
how silly of me to forget that
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38793557
Hi R Edwards,  Not silly at all.  Your solution fixes the problem.  I was just luck to get first :)
Have a nice day!
0
 

Author Closing Comment

by:joaotelles
ID: 38798171
Tks.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question