+5 votes
288 views
How to rename Host CentOS 8 Hostname

in Linux / Unix by (552k points)
reopened | 288 views

1 Answer

+3 votes
Best answer

1. How to know Hostname of Hostname team
2. How to rename Host CentOS 8 using the nmtui command
3. How to rename Host CentOS 8 using the nmcli command
4. How to rename Host CentOS 8 from / etc / sysconfig / network
5. How to rename Host CentOS 8 using the sysctl command

There are several parameters of the server that allow us a direct administration of the same and one of the simplest, but at the same time more important, it is the identifier of the equipment which allows to know it within the network, to administer it specifically and also to carry out an audit control and exclusive support..

This hostname (hostname) can be assigned during the installation of the operating system and in the case of CentOS 8 if we do not specify any name, “localhost” will be assigned and this is verified by executing the hostname command from the console:

image

Obviously, if we only leave “localhost” it can be used for confusion when not knowing what equipment it is and thus defining what type of support or management to perform on it. Today TechnoWikis will explain some simple but effective methods to establish a new hostname in CentOS 8 .


1. How to know Hostname of Hostname team

Step 1

To know with certainty the current name of our machine we can execute any of the following commands:
 hostnamectl hostnamectl status 
Details
This will give us more specific details such as:
  • Host Name (Static hostname).
  • Icon Name
  • Machine ID
  • Chassis type.
  • Virtualization method
  • Boot ID.
  • Kernel current.
  • Operating system used.
  • System type (32 or 64 bits), etc.
image
Step 2

Three types of hostname for CentOS 8
There are three types of hostname for CentOS 8, these are:
  • Static host name: is the name assigned by sysadmin.
  • Transient / dynamic host name: is the name assigned by the DHCP or mDNS server.
  • Pretty host name: is the host name assigned by the administrator or the end user which can be customized according to the person's taste.

Syntax based on the type of host name to use
There are several syntaxes based on the type of host name to use, these are:
  • hostnamectl set-hostname "Machine name"
  • hostnamectl set-hostname “Machine name” --pretty
  • hostnamectl set-hostname “Machine name” --static
  • hostnamectl set-hostname “Machine name” –transient

For example, we will assign the name “TechnoWikis” to the equipment, we will execute the following:
 hostnamectl set-hostname TechnoWikis 
Step 3

We check that it has been assigned with “hostnamectl status”: image
Step 4

Now, if we want to establish a static name we define the following:
 hostnamectl set-hostname TechnoWikis.solvetic.com –static 
image
Step 5

Similarly, to establish a custom name, we must execute the following:
 hostnamectl set-hostname "TechnoWikis team" –pretty 
We check that the “Pretty hostname” line has been added: image
Step 6

Now, if for any reason the name assigned is not to our liking, we can delete it using any of the following forms depending on the type used:
  • hostnamectl set-hostname ""
  • hostnamectl set-hostname "" --static
  • hostnamectl set-hostname "" –pretty
If you wish to modify the name of a device remotely we can use the following:
 ssh root @ ip_server hostnamectl set-hostname "name" 

2. How to rename Host CentOS 8 using the nmtui command

Step 1

This is a user interface tool with which we can apply various changes in equipment parameters at the network level and names, for use it is enough to execute the following:
 nmtui 
In the window that will be displayed we select the option "Set system hostname": image
Step 2

Press Enter and assign the desired name: image
Step 3

With the Tab key we will go to Accept and press Enter to accept the changes and we will see the following: image
Step 4

Press Enter again to accept the changes, after that we will execute the following to apply the changes:
 systemctl restart systemd-hostnamed 
We check the name with hostnamectl status: image

3. How to rename Host CentOS 8 using the nmcli command

Step 1

Another of the useful commands for editing the host name in CentOS 8 is nmcli which manages aspects of the network, to see the current name with this command we will execute the following:
 nmcli general hostname 
image
Step 2

Now, to establish a new name we must execute the following syntax:
 nmcli general hostname "Name" 
image
Note
In case the name is applied immediately we can restart the service by running systemctl restart systemd-hostnamed.

4. How to rename Host CentOS 8 from / etc / sysconfig / network

Step 1

In this directory we can add the desired values ​​of the equipment, for this we access with some editor there:
 nano / etc / sysconfig / network 
There we will add the following:
 NETWORKING = yes HOSTNAME = team_name 
image

We save the changes using the Ctrl + O keys and exit the editor with the Ctrl + X keys..

Step 2

After this we restart the service:
 systemctl restart network 

5. How to rename Host CentOS 8 using the sysctl command

Step 1

Finally, another option is to use the sysctl command for this change, first, we will know the current name by executing:
 sysctl kernel.hostname 
image
Step 2

Now, to make the host name change we must execute the following according to the desired name:
 sysctl kernel.hostname = TechnoWikis.centos8 
image

As you can the options are varied but each of them fulfills the task of editing the host name in CentOS 8 and thus determine the best form of its administration.


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Oct 27, 2019 in Linux / Unix by backtothefuture (552k points) | 248 views
+4 votes
1 answer
asked Oct 8, 2020 in Linux / Unix by backtothefuture (552k points) | 371 views
+5 votes
1 answer
asked Sep 10, 2020 in Linux / Unix by backtothefuture (552k points) | 359 views
+5 votes
1 answer
asked Sep 2, 2020 in Linux / Unix by backtothefuture (552k points) | 2k views
+3 votes
1 answer
asked Aug 13, 2020 in Linux / Unix by backtothefuture (552k points) | 1.9k views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users