Linux mint смена hostname

How to Change Hostname on Linux Mint 20

Hostname enables us to identify a device over the network. The hostname is set on your device during the installation process, or we can change it anytime on our virtual machine. A conflicting situation can arise if more than one device has a similar hostname and is connected to the same network.

Explaining the Hostname

In Linux Mint, we can get the hostname information and edit it using the hostnamectl command. There are following three different types of hostname in Linux Mint:

  • Static: It is a standard hostname displayed over the network and is saved in the /etc/hostname file.
  • Pretty: The pretty hostname is not displayed on the network. It is only displayed to the user.
  • Transient: The transient hostname is the same as the static hostname by default. The Kernel maintains it.

Check the current hostname

We can check the current hostname of the device by using the hostnamectl command:

My current static hostname is Linux.

Changing the Hostname on Linux Mint 20

We can change the Hostname on Linux Mint by two methods:

We will discuss these two methods for changing the hostname.

Using hostnamectl command to change the hostname

It is very simple and straightforward to change the hostname by using the hostnamectl command. Follow the below-given command syntax to change the hostname:

I am changing my Linux Mint system hostname to linuxhint from Linux:

Now let’s check our new hostname with the command:

As you can see from the output that my static hostname is changed to linuxhint.

To change the pretty hostname, use the hostnamectl command with –pretty option as follows:

To check the pretty hostname, use the command:

Читайте также:  Linux какая видеокарта активна

The pretty hostname value is updated.

Changing the hostname from /etc/hostname file

Open the /etc/hostname file in the nano editor by typing on the terminal:

The /etc/hostname file opened in the nano editor.

Now, change the hostname here.

Once you have changed the hostname, save the file and run the hostnamectl command again:

You can see that the static hostname is changed to Linux.

In many situations, the hostname is mapped to the localhost (127.0.0.1). This information is stored in the /etc/hosts file. Open the /etc/hosts file and change the hostname:

Let’s change the linuxhint to Linux, save, and exit the file.

The hostname will be updated successfully.

Conclusion

We can change the hostname on Linux Mint 20 in a couple of ways, i.e., from the hostnamectl command and by editing the /etc/hostname file. This article explains the hostname and describes the methods to change the hostname on Linux Mint 20 system.

About the author

Kamran Sattar Awaisi

I am a software engineer and a research scholar. I like to write article and make tutorial on various IT topics including Python, Cloud Computing, Fog Computing and Deep Learning. I love to use Linux based operating systems.

Источник

How to Set a New Hostname for Your Linux System?

“The hostname of a Linux system is the name with which you can recognize that system. You can manually set up and change this hostname whenever you want. In this guide, we will be focusing on the two methods of setting up a new hostname for your Linux Mint 20.3 system.”

Methods of Setting a New Hostname for a Linux Mint 20.3 System

To set a new hostname for a Linux Mint 20.3 system, you can consider the following two methods:

Method # 1: Temporary Method of Setting a New Hostname

In this method, we will tell you how you can set up a new temporary hostname for your Linux Mint 20.3 system. By “temporary”, we mean that this new hostname will only be there for the current session, and as soon as you will restart your system, its hostname will get back to the previous one. To do this, you will have to perform the steps shown below:

Step # 1: Check the Current Hostname of Your System

Before setting up a new hostname for your Linux Mint 20.3 system, it is good to check the current hostname so that you can set up a different name this time. To check the current hostname of your system, you can run the following command:

The current hostname of our system is highlighted in the image shown below:

Step # 2: Set a New Temporary Hostname for Your System

Now, for setting up a temporary hostname for your system, you can run the following command:

When you execute this command, no output will appear on the terminal; however, when you will check the current hostname again with the “hostnamectl” command, then you will realize that it has been changed successfully, as highlighted in the image below:

Читайте также:  Сменить репозиторий linux mint

Step # 3: Set a Pretty Hostname for Your System (Optional)

Additionally, you can also set up a pretty hostname for your system by executing the command that follows:

Again, after executing this command, you will have to run the “hostnamectl” command to confirm that the pretty hostname for your Linux Mint 20.3 system has successfully been set up, as shown below:

Method # 2: Permanent Method of Setting a New Hostname

Now, we will share with you the method with which you can permanently set up a new hostname for your Linux Mint 20.3 system, i.e., this new hostname will persist even after you will restart your system. To achieve this goal, you will have to perform the following steps:

Step # 1: Change the Hostname in the /etc/hostname File

First, you will have to change the hostname in the /etc/hostname file, for which you will have to access it with the command shown below:

Here, you will be able to see the current hostname of your system as shown in the image that follows:

You will have to change this hostname with a new one and then save your file as shown below:

Step # 2: Change the Hostname in the /etc/hosts File

Now, you have to change the hostname in the /etc/hosts file as well, for which you can access it with the following command:

Again, you will be able to see the current hostname of your system associated with an IP address as highlighted in the image shown below:

You need to change this hostname with a new one, as shown in the following image and then save your file.

To confirm the change in the hostname, you can run the “hostnamectl” command just like we did in our first method. Moreover, for further confirmation, you can also restart your system and check the current hostname. This time, the new hostname will persist even after restarting your Linux Mint 20.3 system.

Conclusion

This guide was meant to share with you the two methods of setting up a new hostname for your Linux Mint 20.3 system. The first method can be used if you just want to change the hostname of your system temporarily. However, if you wish to change the hostname of your system permanently, then you should make use of the second method.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

Источник

How To Change Linux Hostname In Ubuntu, Debian, Mint, Kali, CentOS, RedHat?

Hostname is used to name the systems. Normally the computer networks work with IP addresses in order to identify and communicate. But hostname provides human friendly way to name, identify, communicate with other systems.

Читайте также:  Linux устанавливаем adobe flash player

Example Hostname

Hostname is just a meaningful word for the system administrators to name a system. For example we can use db1 for first database server or app3 for the third application server.

Default Hostname

Hostnames generally set during the system installation. But may change after the installation. Different Linux distributions uses different default hostnames during installation. Here are some of them.

Debian

There are different ways to print default hostname of the system. hostname command is the most known and popular way in order to print hostname of the current system. This command will work on all Linux distributions like Debian, Ubuntu, Mint, Kali, CentOS, RedHat, Fedora etc.

Print Hostname with hostname Command

As we can see the hostname of the given system is poftut1

There is a new command which is supported by all popular Linux distributions like Debian, Ubuntu, Mint, Kali CentOS, RedHat, Fedora. We can use hostnamectl command which will provide the hostname of the current system and more like Chassis , Operating System etc.

Print Hostname with hostnamectl Command

Change Hostname For Ubuntu, Debian, Mint, Kali

Now we will start to learn how to change hostname of the deb based Linux distributions like Ubuntu, Debian, Mint, Kali. These distributions stored hostname settings in /etc/hostname file. So changing this file will change hostname but this will require a reboot to make changes affect.

In this example we will change hostname to the POF1 . We will also use sudo because hostname change operation requires root privileges.

$ sudo echo "POF1" > /etc/hostname

Change Hostname For CentOS, RedHat

Hostname configuration of rpm based disributions like CentOs, RedHat, Fedora are stored in /etc/sysconfig/network . HOSTNAME line provides the hostname of the current system. Example configuration file is like below.

NETWORKING=yes HOSTNAME="poftut1.domainname.com" GATEWAY="192.168.1.1" GATEWAYDEV="eth0" FORWARD_IPV4="yes"

Just put the hostname you want to set to the poftut . But there is also domain name part which is domainname.com . We can set as default or change according to our settings. But if we do not need we can set whatever we want.

In order to make change affect we need to restart network services with the following command.

$ sudo systemctl restart network

Change Hostname with sysctl Command For Ubuntu, Debian, Mint, Kali, CentOS, RedHat

sysctl is a command use to configuration low level settings of a Linux system and kernel. We can use it to set hostname. In this example we will set as poftut1 .

$ sudo sysctl kernel.hostname="poftut1"

Change Hostname with hostnamectl Command For Ubuntu, Debian, Mint, Kali, CentOS, RedHat

We can also use hostnamectl command in order to change current hostname configuration. In this case we will use set-hostname parameter. In this example we will set the hostname as poftut1

$ sudo hostnamectl set-hostname "poftut1"

Источник

Оцените статью
Adblock
detector