Categories: LinuxShellUbuntu

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:

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.

 

Karim Buzdar

About the Author: 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. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago