3 Ways to Find PC’s Hostname Using Linux Terminal

Just as Internet Protocol address or IP address gives an identification to your device, similarly, the 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: Use 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:

Linux terminal

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

$ hostname

Enter the hostname command

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

Hostname displayed on the shell of the Linux system

Method # 2: Use the hostnamectl command

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

Open Shell window

Now type the command:

hostnamectl

in the terminal and press enter.

Enter the command: hostnamectl

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

Details about the Linux system incl. hostname are displayed

Method # 3: Use the cat 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:

Terminal ready to be used

Now type the command:

cat /proc/sys/kernel/hostname

in the terminal and press enter.

Show content of /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 is 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.