hostnamectl command in Linux with Examples Last Updated : 07 Nov, 2019 Comments Improve Suggest changes 2 Likes Like Report hostnamectl command provides a proper API used to control Linux system hostname and change its related settings. The command also helps to change the hostname without actually locating and editing the /etc/hostname file on a given system. Syntax: hostnamectl [OPTIONS...] COMMAND .... Where COMMAND can be any of the following: status: Used to check current hostname settings. set-hostname NAME: Used to set system hostname. set-icon-name NAME: Used to set icon name for host. set-chassis NAME: Set chassis type for host. Types of hostname: Static: Assigned by system admin and it is used to initialize the kernel hostname during boot time. Dynamic or Transient: Assigned by mDNS server or DHCP server during run time. Pretty: It's a high-level hostname assigned by system admin or end-user. Example 1: Running hostnamectl command to check the current host names. We can either execute hostnamectl or hostnamectl status, the result will be same as status option is automatically assumed if no option is given. Example 2: To change static host name to geeksforgeeks. It may require root permission. hostnamectl set-hostname geeksforgeeks --static Now, let us verify the changed hostnames using the hostnamectl command. As you see that the static hostname has been updated to geeksforgeeks. Options: -h, --help: Show help text and exit. --version: Show package version and exit. --transient: This option is used when we particularly want to set transient hostname only. Example: To set transient name to ubuntu. Now, let's check the transient name using hostnamectl. --static: This option is used when we only want to set static hostname. Now, let's verify the change using hostnamectl. --pretty: This option is used when we only want set pretty hostname. The name that is to be set needs to be in the double quote(" "). Verifying the change using following command: hostnamectl --pretty status --no-ask-password: This option do not prompt for password for authentication in any privileged operations. -H --host=[USER@]HOST: This option is used to change the host names remotely. May need root privilege while execution. hostnamectl set-hostname -H [username]@HostName Here, HostName is the remote host that we want to configure. Example: To set server3 as host name on a remote server called as 172.102.2.24 we can use the following command: hostnamectl set-hostname server3 -H [email protected] Create Quiz Comment S suraj1994 Follow 2 Improve S suraj1994 Follow 2 Improve Article Tags : Linux-Unix linux-command Linux-networking-commands Explore Getting Started with LinuxIntroduction to Linux Operating System7 min readLINUX Full Form - Lovable Intellect Not Using XP2 min readDifference between Linux and Windows7 min readLinux Distributions6 min readDifference between Unix and Linux6 min readInstallation with LinuxInstallation of Arch Linux in VirtualBox4 min readFedora Linux Operating System5 min readHow to install Ubuntu on VirtualBox?6 min readHow to Install Linux Mint?3 min readInstallation of Kali Linux in Virtual Machine2 min readHow to Install Linux on Windows PowerShell Subsystem?2 min readHow to Find openSUSE Linux Version?2 min readInstallation of CentOS2 min readLinux CommandsLinux Commands15+ min readEssential Unix Commands7 min readFind Command in Linux with Examples7 min readLinux File SystemLinux File System12 min readLinux File Hierarchy Structure5 min readLinux Directory Structure6 min readLinux KernelLinux Kernel4 min readKernel in Operating System3 min readHow Linux Kernel Boots?11 min readDifference between Operating System and Kernel3 min readLinux Kernel Module Programming: Hello World Program7 min readLinux Loadable Kernel Module7 min readLoadable Kernel Module - Linux Device Driver Development4 min readLinux Networking ToolsNetwork configuration and troubleshooting commands in Linux5 min readHow to configure network interfaces in CentOS?5 min readCommand-Line Tools and Utilities For Network Management in Linux8 min readLinux - Network Monitoring Tools4 min readLinux ProcessProcesses in Linux/Unix5 min readHow to Manage Process in Linux4 min readGetting System and Process Information Using C Programming and Shell in Linux2 min readProcess states and Transitions in a UNIX Process4 min readLinux FirewallLINUX Firewall7 min readiptables command in Linux with Examples7 min readHow to Configure your Linux Firewall - 3 Methods12 min readShell Scripting & Bash ScriptingIntroduction to Linux Shell and Shell Scripting7 min readUnderstanding Terminal, Console, Shell and Kernel3 min readHow to Create a Shell Script in linux7 min readShell Scripting - Different types of Variables4 min readBash Scripting - Introduction to Bash and Bash Scripting12 min readBash Script - Define Bash Variables and its types12 min readShell Scripting - Shell Variables6 min readBash Script - Difference between Bash Script and Shell Script4 min readShell Scripting - Difference between Korn Shell and Bash shell3 min readShell Scripting - Interactive and Non-Interactive Shell3 min readShell Script to Show the Difference Between echo â$SHELLâ and echo â$SHELLâ4 min readLinux Administrator SystemWhat is Linux System Administration?6 min readBeginner's Guide to Linux System Administration5 min readHow to Monitor System Usage, Outages and Troubleshoot Linux Servers6 min readLinux - Systemd and its Components3 min readBoot Process with Systemd in Linux3 min readHow to Control Systemd Services on Remote Linux Server2 min readHow to Start, Stop and Restart Services in Linux Using systemctl Command9 min read Like