Managing NetworkManager with nmcli (with examples)
Introduction
NetworkManager is a powerful tool for managing network connections on Linux systems. nmcli
is a command-line tool that provides an interface to NetworkManager’s functionality. In this article, we will explore the various use cases of the nmcli general
command.
Use Case 1: Show the general status of NetworkManager
The general
command without any arguments provides the general status of NetworkManager.
nmcli general
Motivation: This use case is useful to quickly check the general status of NetworkManager. It provides information such as whether NetworkManager is running or not.
Example Output:
STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
connected full enabled enabled enabled enabled
Use Case 2: Show the hostname of the current device
The general hostname
command displays the hostname of the current device.
nmcli general hostname
Motivation: Sometimes, it is necessary to know the hostname of the device you are working on. This command provides a quick way to retrieve the hostname.
Example Output:
device-hostname
Use Case 3: Change the hostname of the current device
The general hostname
command, when used with sudo
, allows changing the hostname of the current device.
sudo nmcli general hostname new_hostname
Motivation: Changing the hostname of a device can be helpful when setting up a network or for organizational purposes. This command allows administrators to change the hostname easily.
Arguments:
new_hostname
: The desired new hostname for the device.
Use Case 4: Show the permissions of NetworkManager
The general permissions
command displays the permissions of NetworkManager.
nmcli general permissions
Motivation: NetworkManager relies on various permissions to function properly. This command provides an overview of the permissions currently set for NetworkManager.
Example Output:
PERMISSION POLICY
org.freedesktop.NetworkManager.enabled
org.freedesktop.NetworkManager.change-statistics
org.freedesktop.NetworkManager.enable-disable-wifi
org.freedesktop.NetworkManager.enable-disable-wwan
Use Case 5: Show the current logging level and domains
The general logging
command displays the current logging level and domains of NetworkManager.
nmcli general logging
Motivation: Logging is crucial for troubleshooting network issues. This command allows administrators to quickly check the current logging level and domains set for NetworkManager.
Example Output:
LEVEL DOMAIN
INFO default:INFO
Use Case 6: Set the logging level and/or domains
The general logging
command can be used to set the logging level and/or domains for NetworkManager.
nmcli general logging level INFO|OFF|ERR|WARN|DEBUG|TRACE domain domain_1,domain_2,...
Motivation: Configuring the logging level and domains for NetworkManager can help in diagnosing and debugging network-related problems. This command enables administrators to customize the logging settings according to their needs.
Arguments:
INFO|OFF|ERR|WARN|DEBUG|TRACE
: The desired logging level. Choose one from INFO, OFF, ERR, WARN, DEBUG, TRACE.domain_1,domain_2,...
: Comma-separated list of logging domains to be enabled.
Use Case 7: Show the general status of NetworkManager (alternative command)
The g
subcommand can be used as a shorthand for the general
command.
nmcli g
Motivation: This alternative command can be used to quickly check the general status of NetworkManager. It provides the same information as the nmcli general
command.
Example Output:
STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
connected full enabled enabled enabled enabled
Use Case 8: Show more information about nmcli general
If you need more information about the general
command and its options, you can refer to the official documentation.
man nmcli
Motivation: The man
command displays the manual pages for nmcli
. It provides detailed information about all available commands, including the general
command, its options, and their usage.
Example Output: (System documentation will be displayed)