Show Linux hostname with hostnamectl command

Just as Internet Protocol address or IP address gives an identification to your device, similarly, hostname is another parameter through which you can recognize your device. It is a string of human understandable characters. Unlike IP address, hostname of a PC is easy to memorize and recall. For this purpose, one should always know his PC's hostname. In this article, we will tell you how you can find your PC's hostname using Linux Terminal.

Finding PC's Hostname in Linux

To find the hostname of your PC in Linux, you can perform any of the three methods listed below:

Method # 1: using the hostname command

Launch the terminal by pressing Ctrl +T or clicking on the terminal icon displayed on the taskbar or searching for terminal by typing terminal in the search window and pressing enter. The newly opened terminal window is shown below:

Open Linux terminal

Now type the command hostname in the terminal and press enter.

Run the command: hostname

As soon as you will press enter, your PC's hostname will appear on your terminal. It is shown in the image below:

The computer hostname is shown in the Linux terminal

Method # 2: using hostnamectl

Launch the terminal by pressing Ctrl +T or clicking on the terminal icon displayed on the taskbar or searching for terminal by typing terminal in the search window and pressing enter. The newly opened terminal window is shown below:

Linux terminal open

Now type the command hostnamectl in the terminal and press enter.

Type in the hostnamectl command

As soon as you will press enter, your PC's hostname will appear on the terminal window. This is shown below:

Computer details shown by hostnamectl command

Method # 3: check the content of /proc/sys/kernel/hostname

  1. Launch the terminal by pressing Ctrl +T or clicking on the terminal icon displayed on the taskbar or searching for terminal by typing terminal in the search window and pressing enter. The newly opened terminal window is shown below:

Open Linux console

Now type the command:

cat /proc/sys/kernel/hostname

in the terminal and press enter.

Run cat command to show /proc/sys/kernel/hostname

As soon as you will press enter, your PC's hostname will be displayed on the terminal. It is shown below:

Hostname shown

Conclusion

The three different methods listed above are indeed very easy and simple. Now you can find your PC's hostname within seconds and without getting yourself in any sort of trouble. I hope these methods will help you.

How to Find PC’s Hostname Using Linux Terminal
Tagged on:     

Leave a Reply

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

*

Ad #native_company# — #native_desc# #native_cta#