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] Comment S suraj1994 Follow 2 Improve S suraj1994 Follow 2 Improve Article Tags : Linux-Unix linux-command Linux-networking-commands Explore Linux/Unix Tutorial 5 min read Getting Started with LinuxWhat is Linux Operating System 10 min read LINUX Full Form - Lovable Intellect Not Using XP 2 min read Difference between Linux and Windows 7 min read What are Linux Distributions ? 8 min read Difference between Unix and Linux 5 min read Installation with LinuxHow to Install Arch Linux in VirtualBox? 7 min read Fedora Linux Operating System 12 min read How to install Ubuntu on VirtualBox? 6 min read How to Install Linux Mint? 3 min read How to Install Kali Linux on Windows? 2 min read How to Install Linux on Windows PowerShell Subsystem? 2 min read How to Find openSUSE Linux Version? 2 min read How to Install CentOS 2 min read Linux CommandsLinux Commands 15+ min read Essential Unix Commands 7 min read How to Find a File in Linux | Find Command 9 min read Linux File SystemLinux File System 12 min read Linux File Hierarchy Structure 5 min read Linux Directory Structure 6 min read Linux KernelLinux Kernel 4 min read Kernel in Operating System 3 min read How Linux Kernel Boots? 11 min read Difference between Operating System and Kernel 3 min read Linux Kernel Module Programming: Hello World Program 7 min read Linux Loadable Kernel Module 7 min read Loadable Kernel Module - Linux Device Driver Development 4 min read Linux Networking ToolsNetwork configuration and troubleshooting commands in Linux 5 min read How to configure network interfaces in CentOS? 5 min read Command-Line Tools and Utilities For Network Management in Linux 8 min read Linux - Network Monitoring Tools 4 min read Linux ProcessProcesses in Linux/Unix 6 min read How to Manage Process in Linux 4 min read Getting System and Process Information Using C Programming and Shell in Linux 2 min read Process states and Transitions in a UNIX Process 4 min read Linux FirewallLINUX Firewall 7 min read iptables command in Linux with Examples 7 min read How to Configure your Linux Firewall - 3 Methods 12 min read Shell Scripting & Bash ScriptingIntroduction to Linux Shell and Shell Scripting 7 min read What is Terminal, Console, Shell and Kernel? 5 min read How to Create a Shell Script in linux 7 min read Shell Scripting - Different types of Variables 4 min read Bash Scripting - Introduction to Bash and Bash Scripting 12 min read Bash Script - Define Bash Variables and its types 12 min read Shell Scripting - Shell Variables 6 min read Bash Script - Difference between Bash Script and Shell Script 4 min read Shell Scripting - Difference between Korn Shell and Bash shell 3 min read Shell Scripting - Interactive and Non-Interactive Shell 3 min read Shell Script to Show the Difference Between echo â$SHELLâ and echo â$SHELLâ 4 min read Like