Skip to content
Jassweb
  • Home
  • Company
    • About Us
    • Portfolio
    • Blog
    • Career 
  • Services
    • SEO
    • Digital Marketing
    • Web Design & Development
    • E-commerce Solutions
    • Fix Broken Website
    • Website Maintenance
    • Web Hosting & Manage Server
    • Enterprise Automation Solutions
    • Full-Stack SaaS Development
    • Coolify Automation Plugin
  • Shop
  • Tools
  • My Account
    • Cart
    • Checkout
    • My Bookings
      • Appointment canceled
      • Appointment reschedule
  • Contact Us

hostnamectl Linux Commands – Overview with Examples and FAQs

March 10, 2023March 10, 2023 by Jass Web

Introduction

The Linux command hostnamectl is a command line utility used to manage the system hostname. It is used to set the system hostname, static hostname, pretty hostname, and transient hostname. It can also be used to query the system hostname, and to set the system’s NIS domain name. This command is available in most Linux distributions, including Ubuntu, Debian, Fedora, and CentOS.

Examples

The hostnamectl command is used to query and change the system hostname and related settings. It is part of the systemd system and service manager.

Syntax:
hostnamectl [OPTIONS…]

Options:
–static, –transient, –pretty, –pretty-transient, –no-ask-password

Examples:

1. To view the current hostname:
hostnamectl

2. To set a new hostname:
hostnamectl set-hostname newhostname

3. To set a static hostname:
hostnamectl set-hostname –static newhostname
[ad_1]

[ad_2]

Using the Hostnamectl Command in Linux

The hostnamectl command is a powerful tool in Linux that allows you to view and set the system hostname. It is a part of the systemd suite of tools and is used to manage system services, including the hostname. This command is available in most modern Linux distributions, including Ubuntu, Debian, CentOS, and Red Hat.

The hostnamectl command can be used to view the current hostname of the system, as well as set a new hostname. It can also be used to view and set the system’s DNS domain name, and to view and set the system’s NIS domain name. Additionally, it can be used to view and set the system’s static hostname.

To view the current hostname of the system, use the following command:

hostnamectl status

This will display the current hostname, as well as the system’s DNS domain name, NIS domain name, and static hostname. To set a new hostname, use the following command:

hostnamectl set-hostname new_hostname

This will set the system’s hostname to the new_hostname specified. To set the system’s DNS domain name, use the following command:

hostnamectl set-domainname new_domainname

This will set the system’s DNS domain name to the new_domainname specified. To set the system’s NIS domain name, use the following command:

hostnamectl set-nisdomainname new_nisdomainname

This will set the system’s NIS domain name to the new_nisdomainname specified. To set the system’s static hostname, use the following command:

hostnamectl set-static-hostname new_static_hostname

This will set the system’s static hostname to the new_static_hostname specified. The hostnamectl command is a powerful tool in Linux that allows you to view and set the system hostname, DNS domain name, NIS domain name, and static hostname.

Categories Linux Commands Tags adduser or addgroup, agetty, alias, anacron, apropos, apt, apt-get, aptitude, arch, arp, at, atq, atrm, awk, basename, batch, bc, bg, bzip, cal, cat, chgrp, chmod, chown, cksum, clear, cmp, comm, cp, date, dd, df, diff, dir, dmidecode, du, echo, eject, env, exit, expr, factor, find, free, grep, groups, gunzip, gzip, head, history, hostname, hostnamectl, hwclock, hwinfo, id, ifconfig, ionice, iostat, ip, iptables, iw, iwlist, kill, killall, kmod, last, Linux, ln, locate, login, ls, lscpu, lshw, lsof, lsusb, man, mdsum, mkdir, more, mv, nano, nc/netcat, netstat, nice, nmap, nproc, openssl, passwd, pidof, ping, ps, pstree, pwd, rdiff-backup, reboot, rename, rm, rmdir, scp, shutdown, sleep, sort, split, ssh, stat, su, sudo, sum, tac, tail, talk, tar, tee, time, top, touch, tr, tree, uname, uniq, uptime, users, vim or vi, w, wall, watch, wc, wget, whatis, whereis, which, who, xargs, yes, youtube-dl, zcmpor zdiff, zip, zz
9 Ways to Fix Snip and Sketch Not Working on Windows 10 and 11
How Does SFTP Work?
© 2026 Jassweb • Built with GeneratePress