Forrest logo
back to the nmcli tool

nmcli-general:tldr:df182

nmcli-general: Change the hostname of the current device.
$ sudo nmcli general hostname ${new_hostname}
try on your machine

This command is used to change the hostname of a device using the "nmcli" command-line tool with superuser (root) privileges. Here's a breakdown of the command:

  • "sudo": It stands for "superuser do" and it allows the command to be executed with administrative rights. It is typically used to perform tasks that require elevated permissions.

  • "nmcli": It is a command-line tool for managing NetworkManager, a software utility used for configuring network connections on Linux-based systems.

  • "general": It specifies the general settings of NetworkManager.

  • "hostname": It is an option that allows you to get or set the hostname of the device.

  • "${new_hostname}": It is a placeholder variable that represents the desired new hostname for the device. You need to replace "${new_hostname}" with the actual desired hostname when using the command.

By running this command with appropriate privileges and providing the desired new hostname, you can change the hostname of the device.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nmcli tool