Setting the Hostname of Linux Workstation or Server

Postgraduate in Communications Engineering with working experience in the Support Desk and self-study in software development.
Search for a command to run...

Postgraduate in Communications Engineering with working experience in the Support Desk and self-study in software development.
In Linux, links are powerful tools that allow you to create references to files and directories. There are two main types of links: hard links and soft links (also known as symbolic links or symlinks). Understanding the differences between these two ...
The git log command is used to view the commit history of a Git repository. You can customize the output format to show specific details in a more readable or structured way. Below are some useful variations and formatting options for git log: To sh...

Overview This article will teach us how to: Install Ubuntu Server 24.04 on a laptop from scratch Install Ubuntu server by using Vagrant tool with ISO image Prerequisites: A laptop without any OS installed; A virtualization software Virtualbox t...

The /etc/passwd and /etc/shadow files are the backbone of Linux user management. Together, they store user account information and handle authentication securely. This article provides a hands-on guide to understanding these files, their structure, a...

In Linux, links are powerful tools that allow you to create references to files and directories. There are two main types of links: hard links and soft links (also known as symbolic links or symlinks). Understanding the differences between these two ...

A hostname is a human-friendly name given to a computer. It is a unique identifier that allows us to identify the machine in various network communications, making it easier to locate and manage devices.
Type:
hostname
To see where it is stored, type:
cat /etc/hostname
To get the hostname and additional information about your machine:
hostnamectl
To change the hostname, login as root user or use the sudo command:
sudo hostnamectl set-hostname my-private-workstation
If you do not want to restart your terminal, you can force the current terminal to be changed by typing (assuming you use bash):
exec bash
Verify the hostname was changed:
cat /etc/hostname
Check the content of the /cat/hosts file
cat /etc/hosts
Even though the hostnamectl command allows us to set the new hostname, it does not update the /etc/hosts file. This is optional, but highly recommended.
To update the /etc/hosts file, use the vim command:
sudo vim /etc/hosts/
To ping this instance, run:
ping my-private-laptop