nmclinmcli — command-line tool for controlling NetworkManager |
nmcli
[OPTIONS
...] { help
| general
| networking
| radio
| connection
| device
| agent
| monitor
} [COMMAND
] [ARGUMENTS
...]
nmcli is a command-line tool for controlling NetworkManager and reporting network status. It can be utilized as a replacement for nm-applet or other graphical clients. nmcli is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status. See nmcli-examples(7) for ready to run nmcli examples.
Typical uses include:
Scripts: Utilize NetworkManager via nmcli instead of managing network connections manually. nmcli supports a terse output format which is better suited for script processing. Note that NetworkManager can also execute scripts, called "dispatcher scripts", in response to network events. See NetworkManager(8) for details about these dispatcher scripts.
Servers, headless machines, and terminals: nmcli can be used to control NetworkManager without a GUI, including creating, editing, starting and stopping network connections and viewing network status.
|
When using this option nmcli will stop and ask for any missing required arguments, so do not use this option for non-interactive purposes like scripts. This option controls, for example, whether you will be prompted for a password if it is required for connecting to a network. |
||||
|
This option controls color output (using terminal escape sequences).
The actual colors used are configured as described in terminal-colors.d(5). Please refer to the Colors section for a list of color names supported by nmcli. If the environment variable |
||||
|
Instead of conducting the desired action, nmcli will list possible completions for the last argument. This is useful to implement argument completion in shell. The exit status will indicate success or return a code 65 to indicate the last argument is a file name. NetworkManager ships with command completion support for GNU Bash. |
||||
|
Whether to escape If omitted, default is |
||||
|
This option is used to specify what fields (column names) should be
printed. Valid field names differ for specific commands. List available fields
by providing an invalid value to the If omitted, default is |
||||
|
This option is used to print values from specific fields. It is basically
a shortcut for If a section is specified instead of a field, the section name will be printed followed by colon separated values of the fields belonging to that section, all on the same line. |
||||
|
Print help information. |
||||
|
Switch between tabular and multiline output:
If omitted, default is
|
||||
|
Output is pretty. This causes nmcli to produce easily readable outputs for humans, i.e. values are aligned, headers are printed, etc. |
||||
|
When using this option nmcli will display passwords and secrets that might be present in an output of an operation. This option also influences echoing passwords typed by user as an input. |
||||
|
Output is terse. This mode is designed and suitable for computer (script) processing. |
||||
|
Work without a daemon. Makes connection add and connection modify commands accept and produce connection data via standard input/output. Ordinarily, nmcli would communicate with the NetworkManager service. The connection data format (keyfile) is described in nm-settings-keyfile(5) manual. |
||||
|
Show nmcli version. |
||||
|
This option sets a timeout period for which nmcli will wait for NetworkManager to finish operations. It is especially useful for commands that may take a longer time to complete, e.g. connection activation. Specifying a value of |
nmcli general
{ status | hostname | permissions | logging | reload } [ARGUMENTS
...]
Use this command to show NetworkManager status and permissions. You can also get and change system hostname, as well as NetworkManager logging level and domains.
status |
Show overall status of NetworkManager. This is the default action, when no additional command is provided for nmcli general. |
||||||
hostname
[ |
Get and change system hostname. With no arguments, this prints currently configured hostname. When you pass a hostname, it will be handed over to NetworkManager to be set as a new system hostname. Note that the term "system" hostname may also be referred to as
"persistent" or "static" by other programs or tools. The hostname is stored
in |
||||||
permissions |
Show the permissions a caller has for various authenticated operations that NetworkManager provides, like enable and disable networking, changing Wi-Fi and WWAN state, modifying connections, etc. |
||||||
logging
[ |
Get and change NetworkManager logging level and
domains. Without any argument current logging level and domains are shown. In
order to change logging state, provide |
||||||
reload
[ |
Reload NetworkManager's configuration and perform certain updates, like flushing caches or rewriting external state to disk. This is similar to sending SIGHUP to NetworkManager but it allows for more fine-grained control over what to reload through the flags argument. It also allows non-root access via PolicyKit and contrary to signals it is synchronous. Available flags are:
With no flags, everything that is supported is reloaded, which is identical to sending a SIGHUP. See NetworkManager(8) for more details about signals. |
nmcli networking
{ on | off | connectivity } [ARGUMENTS
...]
Query NetworkManager networking status, enable and disable networking.
on, off |
Enable or disable networking control by NetworkManager. All interfaces managed by NetworkManager are deactivated when networking is disabled. |
||||||||||
connectivity [check] |
Get network connectivity state. The optional Possible states are:
|
nmcli radio
{ all | wifi | wwan } [ARGUMENTS
...]
Show radio switches status, or enable and disable the switches.
wifi [ on | off ] |
Show or set status of Wi-Fi in NetworkManager. If no arguments are
supplied, Wi-Fi status is printed; |
wwan [ on | off ] |
Show or set status of WWAN (mobile broadband) in NetworkManager. If no
arguments are supplied, mobile broadband status is printed;
|
all [ on | off ] |
Show or set all previously mentioned radio switches at the same time. |
nmcli monitor
Observe NetworkManager activity. Watches for changes in connectivity state, devices or connection profiles.
See also nmcli connection monitor and nmcli device monitor to watch for changes in certain devices or connections.
nmcli connection
{ show | up | down | modify | add | edit | clone | delete | monitor | reload | load | import | export | migrate } [ARGUMENTS
...]
NetworkManager stores all network configuration as "connections", which are collections of data (Layer2 details, IP addressing, etc.) that describe how to create or connect to a network. A connection is "active" when a device uses that connection's configuration to create or connect to a network. There may be multiple connections that apply to a device, but only one of them can be active on that device at any given time. The additional connections can be used to allow quick switching between different networks and configurations.
Consider a machine which is usually connected to a DHCP-enabled network,
but sometimes connected to a testing network which uses static IP addressing.
Instead of manually reconfiguring eth0 each time the network is changed, the
settings can be saved as two connections which both apply to eth0, one for DHCP
(called default
) and one with the static addressing details (called
testing
). When connected to the DHCP-enabled network the user would run
nmcli con up default , and when connected to the static network the user
would run nmcli con up testing.
show
[ |
List in-memory and on-disk connection profiles, some of which may also be
active if a device is using that connection profile. Without a parameter, all
profiles are listed. When The |
||||||||||||
show
[ |
Show details for specified connections. By default, both static
configuration and active connection data are displayed. When
It is possible to filter the output using the global
You can also specify particular fields. For static configuration, use setting and property names as described in nm-settings-nmcli(5) manual page. For active data use GENERAL, IP4, DHCP4, IP6, DHCP6, VPN. When no command is given to the nmcli connection, the default action is nmcli connection show. |
||||||||||||
up
[ |
Activate a connection. The connection is identified by its name, UUID or
D-Bus path. If If See connection show above for the description of the
Available options are:
|
||||||||||||
down
[ |
Deactivate a connection from a device without preventing the device from further auto-activation. Multiple connections can be passed to the command. Be aware that this command deactivates the specified active connection, but the device on which the connection was active, is still ready to connect and will perform auto-activation by looking for a suitable connection that has the 'autoconnect' flag set. Note that the deactivating connection profile is internally blocked from autoconnecting again. Hence it will not autoconnect until reboot or until the user performs an action that unblocks autoconnect, like modifying the profile or explicitly activating it. In most cases you may want to use device down command instead. The connection is identified by its name, UUID or D-Bus path. If
See connection show above for the description of
the If |
||||||||||||
modify
[ |
Add, modify or remove properties in the connection profile. To set the property just specify the property name followed by the
value. An empty value ( See nm-settings-nmcli(5) for complete reference of setting and property names, their descriptions
and default values. The If you want to append an item or a flag to the existing value, use
The connection is identified by its name, UUID or D-Bus path. If
When the global |
||||||||||||
modify
[ |
Removes a setting from the connection profile. |
||||||||||||
add
[ |
Create a new connection using specified properties. You need to describe the newly created connections with the property and value pairs. See nm-settings-nmcli(5) for the complete reference. The syntax is the same as of the nmcli connection modify command. To construct a meaningful connection you at the very least need to set the
The most typical uses are described in the Examples section. Aside from the properties and values two special options are accepted:
When the global |
||||||||||||
edit
{
[ |
Edit an existing connection or add a new one, using an interactive editor. The existing connection is identified by its name, UUID or D-Bus path. If
The interactive editor will guide you through the connection editing and allow you to change connection parameters according to your needs by means of a simple menu-driven interface. The editor indicates what settings and properties can be modified and provides in-line help. Available options:
See also nm-settings-nmcli(5) for all NetworkManager settings and property names, and their descriptions; and nmcli-examples(7) for sample editor sessions. |
||||||||||||
clone
[ |
Clone a connection. The connection to be cloned is identified by its
name, UUID or D-Bus path. If The new connection profile will be saved as persistent unless
|
||||||||||||
delete
[ |
Delete a configured connection. The connection to be deleted is
identified by its name, UUID or D-Bus path. If If |
||||||||||||
monitor
[ |
Monitor connection profile activity. This command prints a line whenever
the specified connection changes. The connection to be monitored is identified
by its name, UUID or D-Bus path. If Monitors all connection profiles in case none is specified. The command terminates when all monitored connections disappear. If you want to monitor connection creation consider using the global monitor with nmcli monitor command. |
||||||||||||
reload |
Reload all connection files from disk. NetworkManager does not monitor changes to connection. So you need to use this command in order to tell NetworkManager to re-read the connection profiles from disk when a change was made to them. |
||||||||||||
load
|
Load/reload one or more connection files from disk. Use this after manually editing a connection file to ensure that NetworkManager is aware of its latest state. |
||||||||||||
import
[ |
Import an external/foreign configuration as a NetworkManager connection
profile. The type of the input file is specified by Only VPN configurations are supported at the moment. The configuration is
imported by NetworkManager VPN plugins. The imported connection profile will be saved as persistent unless
|
||||||||||||
export
[ |
Export a connection. Only VPN connections are supported at the moment. A proper VPN plugin has
to be installed so that nmcli could export a connection. If no
|
||||||||||||
migrate
[
|
Migrate connection profiles to a different settings plugin, such
as The connection to be migrated is identified by its name, UUID or D-Bus path.
If If no connections are specified, the command acts on all available
connections. Therefore, with no arguments, the command migrates all connection
profiles to the If |
nmcli device
{ status | show | set | up | connect | reapply | modify | down | disconnect | delete | monitor | wifi | lldp | checkpoint } [ARGUMENTS
...]
Show and manage network interfaces.
status |
Print status of devices. This is the default action if no command is specified to nmcli device. |
||||||||||||||
show
[ |
Show detailed information about devices. Without an argument, all devices are examined. To get information for a specific device, the interface name has to be provided. |
||||||||||||||
set
[ifname]
|
Set device properties. |
||||||||||||||
up
|
Connect the device. NetworkManager will try to find a suitable connection that will be activated. It will also consider connections that are not set to auto connect. If no compatible connection exists, a new profile with default settings will be created and activated. This differentiates nmcli connection up ifname "$DEVICE" from nmcli device up "$DEVICE" If |
||||||||||||||
connect
|
Alias for command up. Before version 1.34.0 up was not supported. |
||||||||||||||
reapply
|
Attempt to update device with changes to the currently active connection made since it was last applied. |
||||||||||||||
modify
|
Modify the settings currently active on the device. This command lets you do temporary changes to a configuration active on a particular device. The changes are not preserved in the connection profile. See nm-settings-nmcli(5) for the list of available properties. Please note that some properties can't be changed on an already connected device. |
||||||||||||||
down
|
Disconnect a device and prevent the device from automatically activating further connections without user/manual intervention. Note that disconnecting software devices may mean that the devices will disappear. If |
||||||||||||||
disconnect
|
Alias for command down. Before version 1.34.0 down was not supported. |
||||||||||||||
delete
|
Delete a device. The command removes the interface from the system. Note that this only works for software devices like bonds, bridges, teams, etc. Hardware devices (like Ethernet) cannot be deleted by the command. If |
||||||||||||||
monitor
[ |
Monitor device activity. This command prints a line whenever the specified devices change state. Monitors all devices in case no interface is specified. The monitor terminates when all specified devices disappear. If you want to monitor device addition consider using the global monitor with nmcli monitor command. |
||||||||||||||
wifi
[
list
[ |
List available Wi-Fi access points. The By default, nmcli ensures that the access point list
is no older than 30 seconds and triggers a network scan if necessary. The
|
||||||||||||||
wifi
connect
|
Connect to a Wi-Fi network specified by SSID or BSSID. The command
finds a matching connection or creates one and then activates it on a device.
This is a command-line counterpart of clicking an SSID in a GUI client. If
a connection for the network already exists, it is possible to bring up
(activate) the existing profile as follows:
nmcli con up id If Available options are:
|
||||||||||||||
wifi
hotspot
[ |
Create a Wi-Fi hotspot. The command creates a hotspot connection profile according to Wi-Fi device capabilities and activates it on the device. The hotspot is secured with WPA if device/driver supports that, otherwise WEP is used. Use connection down or device down to stop the hotspot. Parameters of the hotspot can be influenced by the optional parameters:
|
||||||||||||||
wifi
rescan
[ |
Request that NetworkManager immediately re-scan for
available access points. NetworkManager scans Wi-Fi networks periodically, but
in some cases it can be useful to start scanning manually (e.g. after resuming
the computer). By using This command does not show the APs, use nmcli device wifi list for that. |
||||||||||||||
wifi
show-password
[ |
Show the details of the active Wi-Fi networks, including the secrets. |
||||||||||||||
lldp
[
list
[ |
Display information about neighboring devices learned through the Link
Layer Discovery Protocol (LLDP). The |
||||||||||||||
checkpoint
[ |
Runs the command with a configuration checkpoint taken and asks for a confirmation when finished. When the confirmation is not given, the checkpoint is automatically restored after timeout. This allows doing disruptive configuration changes over remote connections with an option of restoring the network configuration to a known good state in case of an error. If the a list of interface names is specified, the checkpoint is taken, the checkpoint is takes only on the specified devices. Otherwise a checkpoint is taken for all devices. Currently the timeout defaults to 15 seconds. This may change in a future version. |
nmcli agent
{ secret | polkit | all }
Run nmcli as a NetworkManager secret agent, or polkit agent.
secret |
Register nmcli as a NetworkManager secret agent and listen for secret requests. You usually do not need this command, because nmcli can handle secrets when connecting to networks. However, you may find the command useful when you use another tool for activating connections and you do not have a secret agent available (like nm-applet). |
polkit |
Register nmcli as a polkit agent for the user session and listen for
authorization requests. You do not usually need this command, because nmcli can
handle polkit actions related to NetworkManager operations (when run with
|
all |
Runs nmcli as both NetworkManager secret and a polkit agent. |
Implicit coloring can be disabled by an empty file
/etc/terminal-colors.d/nmcli.disable
.
See terminal-colors.d(5) for more details about colorization configuration. The logical color names supported by nmcli are:
|
A connection that is active. |
|
Connection that is being activated. |
|
Connection that is being disconnected. |
|
Connection representing configuration created externally to NetworkManager. |
|
Connection whose details is the user not permitted to see. |
|
Connection that uses deprecated settings. It might not be possible to activate it. |
|
Connectivity state when Internet is reachable. |
|
Connectivity state when only a local network reachable. |
|
Connectivity state when the network is disconnected. |
|
Connectivity state when a captive portal hijacked the connection. |
|
Connectivity state when a connectivity check didn't run. |
|
Device that is connected. |
|
Device that is being configured. |
|
Device that is not connected. |
|
Device configured externally to NetworkManager. |
|
Warning of a missing device firmware. |
|
Warning of a missing device plugin. |
|
Device that is not available for activation. |
|
Device is disabled by software or hardware kill switch. |
|
Notice that the NetworkManager daemon is available. |
|
Notice that the NetworkManager daemon is being initially connected. |
|
Notice that the NetworkManager daemon is not available. |
|
An action that requires user authentication to get permission. |
|
An action that is not permitted. |
|
An action that is permitted. |
|
Prompt in interactive mode. |
|
Indication that NetworkManager in suspended state. |
|
Indication that NetworkManager in connected to Internet. |
|
Indication that NetworkManager in local network. |
|
Indication that NetworkManager in connected to networks other than Internet. |
|
Indication that NetworkManager is establishing a network connection. |
|
Indication that NetworkManager is disconnected from a network. |
|
Indication that NetworkManager is being disconnected from a network. |
|
Wi-Fi network with an excellent signal level. |
|
Wi-Fi network with a fair signal level. |
|
Wi-Fi network with a good signal level. |
|
Wi-Fi network with a poor signal level. |
|
Wi-Fi network that hasn't been actually seen (a hidden AP). |
|
Wi-Fi network that might be impossible to connect to due to use of deprecated functionality. |
|
A property that is turned off. |
|
A property that is turned on. |
nmcli's behavior is affected by the following environment variables.
|
If set to a non-empty string value, it overrides the values of all the other internationalization variables. |
|
Determines the locale to be used for internationalized messages. |
|
Provides a default value for the internationalization variables that are unset or null. |
|
Default to not producing colored and paged output. The
|
|
Filter to pipe the output through if it doesn't fit on a screen. Can be a file name of an executable or a shell command. Empty string to disable the functionality. Note that the pager command is expected to handle wide characters
and ANSI escape sequences for changing colors (unless they're disabled).
nmcli sets up the environment variables
If unspecified, pager(1), less(1) and more(1) will be tried (in that order). |
|
Terminal type. If Terminal types other than |
Be aware that nmcli is localized and that is why the output depends on your environment. This is important to realize especially when you parse the output.
Call nmcli as LC_ALL=C nmcli to
be sure the locale is set to C
while executing in a script.
LC_ALL
, LC_MESSAGES
, LANG
variables specify the LC_MESSAGES
locale category (in that
order), which determines the language that nmcli uses for
messages. The C
locale is used if none of these variables are set, and this
locale uses English messages.
nmcli exits with status 0 if it succeeds, a value greater than 0 is returned if an error occurs.
0 |
Success – indicates the operation succeeded. |
1 |
Unknown or unspecified error. |
2 |
Invalid user input, wrong nmcli invocation. |
3 |
Timeout expired (see |
4 |
Connection activation failed. |
5 |
Connection deactivation failed. |
6 |
Disconnecting device failed. |
7 |
Connection deletion failed. |
8 |
NetworkManager is not running. |
10 |
Connection, device, or access point does not exist. |
65 |
When used with |
This section presents various examples of nmcli usage. If you want even more, please refer to nmcli-examples(7) manual page.
|
tells you whether NetworkManager is running or not. |
|
shows the overall status of NetworkManager. |
|
switches Wi-Fi off. |
|
lists all connections NetworkManager has. |
|
shows all configured connections in multi-line mode. |
|
lists all currently active connections. |
|
shows all connection profile names and their auto-connect property. |
|
shows details for "My default em1" connection profile. |
|
shows details for "My Home Wi-Fi" connection profile with all passwords.
Without |
|
shows details for "My default em1" active connection, like IP, DHCP information, etc. |
|
shows static configuration details of the connection profile with "My wired connection" name. |
|
activates the connection profile with name "My wired connection" on interface eth0. The -p option makes nmcli show progress of the activation. |
|
connects the Wi-Fi connection with UUID 6b028a27-6dc9-4411-9886-e9ad1dd43761 to the AP with BSSID 00:3A:98:7C:42:D3. |
|
shows the status for all devices. |
|
disconnects a connection on interface em2 and marks the device as unavailable for auto-connecting. As a result, no connection will automatically be activated on the device until the device's 'autoconnect' is set to TRUE or the user manually activates a connection. |
|
shows details for wlan0 interface; only GENERAL and WIFI-PROPERTIES sections will be shown. |
|
shows all available connection profiles for your Wi-Fi interface wlp3s0. |
|
lists available Wi-Fi access points known to NetworkManager. |
|
creates a new connection named "My cafe" and then connects it to "Cafe Hotspot 1" SSID using password "caffeine". This is mainly useful when connecting to "Cafe Hotspot 1" for the first time. Next time, it is better to use nmcli con up id "My cafe" so that the existing connection profile can be used and no additional is created. |
|
creates a hotspot profile and connects it. Prints the hotspot password the user should use to connect to the hotspot from other devices. |
|
starts IPv4 connection sharing using em1 device. The sharing will be active until the device is disconnected. |
|
temporarily adds an IP address to a device. The address will be removed when the same connection is activated again. |
|
non-interactively adds an Ethernet connection tied to eth0 interface with
automatic IP configuration (DHCP), and disables the connection's |
|
non-interactively adds a VLAN connection with ID 55. The connection will use eth0 and the VLAN interface will be named Maxipes-fik. |
|
non-interactively adds a connection that will use eth0 Ethernet interface and only have an IPv6 link-local address configured. |
|
edits existing "ethernet-em1-2" connection in the interactive editor. |
|
adds a new Ethernet connection in the interactive editor. |
|
modifies 'autoconnect' property in the 'connection' setting of 'ethernet-2' connection. |
|
modifies 'mtu' property in the 'wifi' setting of 'Home Wi-Fi' connection. |
|
sets manual addressing and the addresses in em1-1 profile. |
|
appends a Google public DNS server to DNS servers in ABC profile. |
|
removes the specified IP address from (static) profile ABC. |
|
imports an OpenVPN configuration to NetworkManager. |
|
exports NetworkManager VPN profile corp-vpnc as standard Cisco (vpnc) configuration. |
nmcli accepts abbreviations, as long as they are a unique prefix in the set of possible options. As new options get added, these abbreviations are not guaranteed to stay unique. For scripting and long term compatibility it is therefore strongly advised to spell out the full option names.
There are probably some bugs. If you find a bug, please report it to your distribution
or upstream at https://gitlab.freedesktop.org/NetworkManager/NetworkManager
.
nmcli-examples(7), nm-settings-nmcli(5), nm-online(1), NetworkManager(8), NetworkManager.conf(5), nm-applet(1), nm-connection-editor(1), terminal-colors.d(5).