Gice

Technology and General Blog

The “hostname” command in Linux is made use of to examine the technique name that is assigned to a Linux machine. Having said that, this command can also be paired up with other various flags for finding distinct outputs. We will try to throw light-weight on some illustrations of the “hostname” command in Linux in this short article.

Basic Syntax of the “hostname” Command:

The basic syntax of the “hostname” command in Linux is demonstrated underneath:

In this article, you can swap “parameter” with any flags or possibilities utilized with the “hostname” command. Some of people flags or possibilities are also described in the illustrations below. Nonetheless, if you want to execute the uncomplicated “hostname” command, you can also do that with out stating any parameter.

Illustrations of Linux “hostname” Command:

For discovering the usage of the “hostname” command in Linux, you can go by way of the following examples:

Illustration # 1: Test the Hostname of your Linux System:

This command is most normally used for examining the hostname of your Linux procedure by functioning it in the manner revealed below:

Our Linux system’s hostname is shown in the pursuing picture:

Illustration # 2: Check the IP Tackle from the Hostname of your Linux System:

You can also test the IP deal with that is assigned to your Linux equipment from its hostname by applying the “hostname” command with the “-i” parameter as follows:

The IP deal with against the hostname of our Linux technique is demonstrated in the picture below:

Case in point # 3: Test the Fully Experienced Domain Name of your Linux System:

If you want to verify the absolutely certified domain title of your Linux technique, then you can use the “-f” flag with the “hostname” command as follows:

The fully capable area identify of our Linux procedure is proven in the picture down below:

Example # 4: Test the Alias of the Hostname of your Linux Program:

At instances, buyers also established aliases from the hostnames of their devices. If you want to check out the alias from the hostname of your system (if it exists), then you can use the “-a” parameter with the “hostname” command as follows:

Because we had not set up an alias for our system’s hostname, hence, we were introduced with a blank output, as demonstrated in the image down below:

Example # 5: Check the Short Hostname of your Linux Program:

If there is a dot in your hostname, then the short hostname refers to the portion of your hostname prior to that dot. You can show the limited hostname of your Linux program by making use of the “-s” flag with the “hostname” command as follows:

Since we did not have a dot in our system’s hostname, consequently, the quick hostname of our Linux process is the identical as our real hostname, which is proven in the graphic down below:

Case in point # 6: Improve the Hostname of your Linux Technique:

If you want to alter the hostname of your Linux system, then you can also do that although working with the “hostname” command in the adhering to fashion:

$ sudo hostname NewHostName

Here, you will have to replace NewHostName with any desired new hostname you want to set up for your Linux process. This command will not present any output on the terminal upon effective execution.

You can verify if a new hostname has been set up for your method or not by executing the command revealed below:

From the output of the earlier mentioned-pointed out command, it is fairly evident that our hostname has been adjusted correctly, as demonstrated in the adhering to picture:

Summary:

We talked about the six various examples of using the “hostname” command in Linux in this report. To understand more about the use of this command in Linux, you can run the “hostname –help” command in your system’s terminal.

Leave a Reply

Your email address will not be published. Required fields are marked *