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:
Now type the command hostname in the terminal and press enter.
$ hostname
As soon as you will press enter, your PC’s hostname will appear on your terminal. It is shown in the image below:
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:
Now type the command:
hostnamectl
in the terminal and press enter.
As soon as you will press enter, your PC’s hostname will appear on the terminal window. This is shown below:
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:
Now type the command:
cat /proc/sys/kernel/hostname
in the terminal and press enter.
As soon as you will press enter, your PC’s hostname will be displayed on the terminal. It is shown below:
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.