Linux Commands Helper

💬 Your AI-powered Linux assistant

hostname Command - Show or Set System Hostname

The hostname command displays or sets the system's host name. The host name is used to identify the system on a network.

Syntax

hostname [options] [new_hostname]

Examples

hostname

Display the current host name.

sudo hostname newhost

Temporarily set the host name to newhost (until reboot).

echo "newhost" | sudo tee /etc/hostname sudo systemctl restart systemd-logind.service

Permanently change the host name (Debian/Ubuntu style).

Notes

  • Changing the host name may require root privileges.
  • Permanent changes usually require editing /etc/hostname and restarting related services.
  • On modern systems, use hostnamectl for persistent changes.

© 2025 Linux Commands Helper. All rights reserved.

This project is under construction. Feedback and contributions are welcome.

Fazier badgeFeatured on Startup Fame