NMCLI(1)

๐ŸŽ€ NMCLI ๐ŸŽ€ โ€” command-line tool for controlling NetworkManager

ok so this is NMCLI(1) from the General Commands Manual and bestie, buckle up, because this is the moment your terminal becomes the main character. ๐Ÿ’…

โœจ NAME โœจ

nmcli โ€” the command-line tool for controlling NetworkManager. that's it, that's the whole vibe. ๐Ÿ‘‘

โœจ SYNOPSIS โœจ

nmcli [OPTIONS...] {help | general | networking | radio | connection |
      device | agent | monitor} [COMMAND] [ARGUMENTS...]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

nmcli is a command-line tool for controlling NetworkManager and reporting network status. she can 100% be used as a replacement for nm-applet or any of those other graphical clients โ€” no GUI needed, we're doing this in the terminal like legends. nmcli creates, displays, edits, deletes, activates and deactivates network connections, AND controls and displays network device status. if you want ready-to-run examples, go look at nmcli-examples(7) โ€” she ate with that one. โœจ

Typical uses include:

  • Scripts: use NetworkManager via nmcli instead of managing network connections by hand. nmcli supports a terse output format that's way better suited for script processing. ngl tho, NetworkManager can also execute scripts called "dispatcher scripts" in response to network events โ€” check NetworkManager(8) for all the deets on those. ๐Ÿซถ
  • Servers, headless machines, and terminals: nmcli lets you control NetworkManager without any GUI at all, including creating, editing, starting and stopping network connections and viewing network status. headless girlies stay winning. ๐Ÿ’€

๐Ÿ’– OPTIONS ๐Ÿ’–

  • -a, --ask โ€” with this option nmcli will literally stop and ask you for any missing required arguments, so do NOT use this for non-interactive purposes like scripts, bestie. this option controls, for example, whether you get prompted for a password if one's required to connect to a network. ๐Ÿ™ˆ
  • -c, --colors {yes | no | auto} โ€” controls color output (using terminal escape sequences). yes enables colors, no disables them, auto only produces colors when standard output is directed to a terminal. the default value is auto. โœจ

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 nmcli supports.

if the environment variable NO_COLOR is set (to any non-empty value), then coloring is disabled with mode "auto". if the environment variable CLICOLOR_FORCE is set (to any non-empty value), then coloring is enabled with mode "auto". explicitly enabling coloring overrides the environment variable. ๐Ÿ’…

  • --complete-args โ€” instead of doing the thing you actually asked for, nmcli will list possible completions for the last argument. super useful for implementing argument completion in a 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. slay.

  • -e, --escape {yes | no} โ€” whether to escape : and \ characters in terse tabular mode. the escape character is \. if omitted, the default is yes.
  • -f, --fields {field1,field2... | all | common} โ€” specifies what fields (column names) should be printed. valid field names differ per command, so if you want the list of available fields just feed the --fields option an invalid value and she'll tell you. ๐Ÿ‘€ all prints all valid field values of the command. common prints common field values of the command. if omitted, default is common.
  • -g, --get-values {field1,field2... | all | common} โ€” prints values from specific fields. it's basically a shortcut for --mode tabular --terse --fields, and it's the convenient way to grab values for particular fields. the values are printed one per line, no headers. ๐ŸŽ€

if you specify a section instead of a field, the section name gets printed followed by colon-separated values of the fields belonging to that section, all on the same line.

  • -h, --help โ€” print help information. the classic.
  • -m, --mode {tabular | multiline} โ€” switch between tabular and multiline output:
    • tabular โ€” output is a table where each line describes a single entry. columns define particular properties of the entry.
    • multiline โ€” each entry comprises multiple lines, each property on its own line. the values are prefixed with the property name.

if omitted, the default is tabular for most commands. for commands producing more structured info that can't fit on a single line, the default is multiline. currently, those are:

  • nmcli connection show ID
  • nmcli device show
  • -p, --pretty โ€” output is pretty. this makes nmcli produce easily readable output for humans, i.e. values are aligned, headers are printed, etc. ๐Ÿ’–
  • -s, --show-secrets โ€” with this option nmcli will display passwords and secrets that might be present in the output of an operation. this option also influences whether passwords you type as input get echoed. โš ๏ธ careful with that one.
  • -t, --terse โ€” output is terse. this mode is designed and suitable for computer (script) processing. ๐Ÿค–
  • --offline โ€” work without a daemon. makes connection add and connection modify commands accept and produce connection data via standard input/output. ordinarily, nmcli would be communicating with the NetworkManager service.

the connection data format (keyfile) is described in the nm-settings-keyfile(5) manual. ๐Ÿ“–

  • -v, --version โ€” show nmcli version. ๐Ÿ’โ€โ™€๏ธ
  • -w, --wait seconds โ€” sets a timeout period for which nmcli will wait for NetworkManager to finish operations. it's especially useful for commands that may take a longer time to complete, e.g. connection activation. โณ

specifying a value of 0 tells nmcli not to wait but to exit immediately with a status of success. the default value depends on the executed command.


๐Ÿฆ‹ GENERAL COMMANDS ๐Ÿฆ‹

nmcli general {status | hostname | permissions | logging | reload}
              [ARGUMENTS...]

use this command to show NetworkManager status and permissions. you can also get and change the system hostname, plus NetworkManager logging level and domains. honestly iconic.

  • status โ€” show the overall status of NetworkManager. this is the default action when no additional command is provided for nmcli general.
  • hostname [hostname] โ€” get and change the system hostname. with no arguments, this prints the currently configured hostname. when you pass a hostname, it gets handed over to NetworkManager to be set as the 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 the /etc/hostname file in most distributions. for example, the systemd-hostnamed service uses the term "static" hostname and it only reads the /etc/hostname file when it starts. iykyk.

  • 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 [level level] [domains domains...] โ€” get and change NetworkManager logging level and domains. with no argument, current logging level and domains are shown. to change the logging state, provide level and/or domain parameters. see NetworkManager.conf(5) for available level and domain values.
  • reload [flags...] โ€” 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, except it gives you more fine-grained control over what to reload via the flags argument. it also allows non-root access via PolicyKit, and โ€” unlike signals โ€” it's synchronous. available flags are:
    • conf โ€” reload the NetworkManager.conf configuration from disk. note that this does not include connections, which can be reloaded through nmcli connection reload instead.
    • dns-rc โ€” update DNS configuration, which usually involves writing /etc/resolv.conf anew. this is equivalent to sending the SIGUSR1 signal to the NetworkManager process.
    • dns-full โ€” restart the DNS plugin. this is for example useful when using the dnsmasq plugin, which uses additional configuration in /etc/NetworkManager/dnsmasq.d. if you edit those files, you can restart the DNS plugin. โš ๏ธ this action shortly interrupts name resolution.

with no flags, everything that's supported gets reloaded, which is identical to sending a SIGHUP. see NetworkManager(8) for more details about signals. ๐Ÿ“ก


๐ŸŒˆ NETWORKING CONTROL COMMANDS ๐ŸŒˆ

nmcli networking {on | off | connectivity} [ARGUMENTS...]

query NetworkManager networking status, enable and disable networking. the power of on/off, truly.

  • on, off โ€” enable or disable networking control by NetworkManager. all interfaces managed by NetworkManager are deactivated when networking is disabled, so like... know that before you hit it. ๐Ÿ˜ญ
  • connectivity [check] โ€” get the network connectivity state. the optional check argument tells NetworkManager to re-check the connectivity, otherwise the most recent known connectivity state is displayed without re-checking.

possible states are:

  • none โ€” the host is not connected to any network.
  • portal โ€” the host is behind a captive portal and cannot reach the full Internet.
  • limited โ€” the host is connected to a network, but it has no access to the Internet.
  • full โ€” the host is connected to a network and has full access to the Internet.
  • unknown โ€” the connectivity status cannot be found out.

๐Ÿ“ป RADIO TRANSMISSION CONTROL COMMANDS ๐Ÿ“ป

nmcli radio {all | wifi | wwan} [ARGUMENTS...]

show radio switches status, or enable and disable the switches. ๐Ÿ“ถ

  • wifi [on | off] โ€” show or set the status of Wi-Fi in NetworkManager. if no arguments are supplied, Wi-Fi status is printed; on enables Wi-Fi; off disables Wi-Fi.
  • wwan [on | off] โ€” show or set the status of WWAN (mobile broadband) in NetworkManager. if no arguments are supplied, mobile broadband status is printed; on enables mobile broadband, off disables it.
  • all [on | off] โ€” show or set all the previously mentioned radio switches at the same time. queen of efficiency. ๐Ÿ‘‘

๐Ÿ‘€ ACTIVITY MONITOR ๐Ÿ‘€

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. ๐Ÿงš


๐Ÿ’œ CONNECTION MANAGEMENT COMMANDS ๐Ÿ’œ

nmcli connection {show | up | down | modify | add | edit | clone |
                 delete | monitor | reload | load | import | export |
                 migrate} [ARGUMENTS...]

okay so first, the whole concept ๐Ÿ’ก NetworkManager keeps all of its network configuration as "connections" โ€” and a connection is just a bundle of data (Layer2 details, IP addressing, all of it) that describes how to create or connect to a network. A connection is "active" when some device is literally using that connection's config to create or connect to a network. A single device might have multiple connections that apply to it, but ngl only one of them can be active on that device at any given moment โ€” the extra ones are just sitting there so you can switch between different networks and configs super fast. ๐Ÿฆ‹

Picture a machine that's normally on a DHCP-enabled network, but sometimes gets plugged into a testing network using static IP addressing. Instead of manually reconfiguring eth0 every single time, you just save two connections that both apply to eth0: one for DHCP (called default) and one with the static addressing deets (called testing). On the DHCP network you run nmcli con up default, and on the static network you run nmcli con up testing. slay, zero pain. โœจ


๐ŸŒธ show ๐ŸŒธ

show [--active] [--order [+-]category:...]

Lists in-memory and on-disk connection profiles โ€” some of which might also be active if a device is currently using that profile. No parameter? You get all profiles, bestie. Pass --active and only the active profiles show up. ๐Ÿ’…

The --order option is how you get custom ordering of connections. You can order by active status (active), name (name), type (type) or D-Bus path (path). If two connections tie on one sort category, just add another category after it. The default sorting order is exactly equivalent to --order active:name:path. A + prefix (or no prefix at all) means ascending order โ€” alphabetically or numerically โ€” and - means reverse (descending) order. Category names can be abbreviated, e.g. --order -a:na. ๐ŸŽ€

show [--active] [id | uuid | path | apath] ID...

Show details for the connections you name. By default you get both static configuration and active connection data. With --active, only the active profiles are taken into account. And use the global --show-secrets option if you want to display secrets associated with the profile. ๐Ÿ™ˆ

The id, uuid, path and apath keywords are there for when your ID is ambiguous. The optional ID-specifying keywords are:

  • id โ€” the ID denotes a connection name.
  • uuid โ€” the ID denotes a connection UUID.
  • path โ€” the ID denotes a D-Bus static connection path in the format of /org/freedesktop/NetworkManager/Settings/num or just num.
  • apath โ€” the ID denotes a D-Bus active connection path in the format of /org/freedesktop/NetworkManager/ActiveConnection/num or just num.

You can also filter the output using the global --fields option. Use these values:

  • profile โ€” only shows static profile configuration.
  • active โ€” only shows active connection data (when the profile is active).

And you can go deeper and specify particular fields, too. For static configuration, use setting and property names as described in the nm-settings-nmcli(5) manual page. For active data, use GENERAL, IP4, DHCP4, IP6, DHCP6, VPN. ๐Ÿ‘‘

When no command is given to nmcli connection, the default action is nmcli connection show. (it's giving "just does the right thing" energy ๐Ÿ’–)

๐Ÿ”ฅ up ๐Ÿ”ฅ

up [id | uuid | path] ID [ifname ifname] [ap BSSID] [passwd-file file]

Activate a connection, periodt. The connection is identified by its name, UUID or D-Bus path. If the ID is ambiguous, use the keyword id, uuid or path. When you need a particular device to activate the connection on, hand it the ifname option with the interface name. If the ID isn't given, then ifname is required and NetworkManager will activate the best available connection for that ifname. For a VPN connection, the ifname option specifies the device of the base connection. And the ap option specifies what particular AP should be used in the case of a Wi-Fi connection. ๐ŸŒˆ

If the --wait option is not specified, the default timeout will be 90 seconds. โณ

See connection show above for the description of the ID-specifying keywords.

Available options are:

  • ifname โ€” interface that will be used for activation.
  • ap โ€” BSSID of the AP which the command should connect to (for Wi-Fi connections).
  • passwd-file โ€” some networks may require credentials during activation. You can give these credentials using this option. Each line of the file should contain one password in the form:
setting_name.property_name:the password

For example, for WPA Wi-Fi with PSK, the line would be

802-11-wireless-security.psk:secret12345

For 802.1X password, the line would be

802-1x.password:my 1X password

nmcli also accepts wifi-sec and wifi strings instead of 802-11-wireless-security. When NetworkManager requires a password and it isn't given, nmcli will ask for it when run with --ask. If --ask wasn't passed, NetworkManager can ask another secret agent that may be running โ€” typically a GUI secret agent, such as nm-applet or gnome-shell. ๐Ÿซถ


๐Ÿ’€ down ๐Ÿ’€

down [id | uuid | path | apath] ID...

Deactivate a connection from a device without preventing the device from further auto-activation. You can pass multiple connections to the command, no cap.

okay be aware of this bestie: the 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. Also note that the deactivating connection profile is internally blocked from autoconnecting again โ€” so it won't autoconnect until reboot, or until the user does something 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 ID is ambiguous, a keyword id, uuid, path or apath can be used.

See connection show above for the description of the ID-specifying keywords.

If the --wait option is not specified, the default timeout will be 10 seconds. โณ

๐Ÿฆ‹ modify ๐Ÿฆ‹

modify [--temporary] [id | uuid | path] [ID]
{option value | [+|-]setting.property value}...

Add, modify or remove properties in the connection profile. iconique behavior honestly.

To set a property, just specify the property name followed by the value. An empty value ("") resets the property value to the default. โœจ

See nm-settings-nmcli(5) for the complete reference of setting and property names, their descriptions and default values. Both the setting and the property can be abbreviated โ€” provided they're unique.

If you want to append an item or a flag to the existing value, use the + prefix on the property name or alias. If you want to remove items from a container-type or flag property, use the - prefix. For certain properties you can also remove elements by specifying the zero-based index(es). The + and - modifiers only have a real effect for properties that actually support them โ€” for example multi-value (container) properties or flags like ipv4.dns, ip4, ipv4.addresses, bond.options, 802-1x.phase1-auth-flags etc. ๐Ÿ”ฅ

The connection is identified by its name, UUID or D-Bus path. If ID is ambiguous, a keyword id, uuid or path can be used. The ID is not used with the global --offline option.

When the global --offline is used, the command reads the connection from the standard input and prints the modified connection to standard output, instead of making the NetworkManager daemon act upon the specified connection. ๐ŸŽ€

modify [--temporary] [id | uuid | path] ID remove setting

Removes a setting from the connection profile. bye-setting energy ๐Ÿ’…


โญ add โญ

add [save {yes | no}] {option value | [+|-]setting.property value}...

Create a brand new connection using the properties you specify. ๐ŸŽ€

You need to describe the newly created connection with the property and value pairs โ€” see nm-settings-nmcli(5) for the complete reference. The syntax is the same as the nmcli connection modify command.

To construct a meaningful connection, at the very least you need to set the connection.type property (or use the type alias) to one of the known NetworkManager connection types:

  • 6lowpan
  • 802-11-olpc-mesh (alias olpc-mesh)
  • 802-11-wireless (alias wifi)
  • 802-3-ethernet (alias ethernet)
  • adsl
  • bluetooth
  • bond
  • bond-slave (deprecated for ethernet with controller)
  • bridge
  • bridge-slave (deprecated for ethernet with controller)
  • cdma
  • dummy
  • generic
  • gsm
  • hsr
  • infiniband
  • ip-tunnel
  • ipvlan
  • loopback
  • macsec
  • macvlan
  • olpc-mesh
  • ovs-bridge
  • ovs-interface
  • ovs-port
  • pppoe
  • team
  • team-slave (deprecated for ethernet with controller)
  • tun
  • veth
  • vlan
  • vpn
  • vrf
  • vxlan
  • wifi-p2p
  • wimax
  • wireguard
  • wpan

The most typical uses are described in the EXAMPLES section. ๐Ÿ‘‘

Aside from the properties and values, two special options are accepted:

  • save โ€” controls whether the connection should be persistent, i.e. whether NetworkManager should store it on disk (default: yes).
  • -- โ€” if a single -- argument is encountered it is ignored. This is for compatibility with older versions of nmcli.

When the global --offline is used, the command prints the resulting connection to standard output instead of actually adding the connection via the NetworkManager daemon. ๐Ÿซถ


๐Ÿงš edit ๐Ÿงš

edit {[id | uuid | path] ID | [type type] [con-name name] }

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 ID is ambiguous, a keyword id, uuid, or path can be used โ€” see connection show above for the whole rundown on those ID-specifying keywords. And if you justโ€ฆ don't give an ID at all? Bestie, that means a brand new connection is getting added. Fresh profile, who dis ๐Ÿ’…

The interactive editor is literally gonna walk you through the connection editing, letting you change connection parameters however you need via a simple menu-driven interface. It tells you what settings and properties can be modified and gives you in-line help the whole way. It's giving tour guide energy ๐Ÿงš

Available options:

  • type โ€” the type of the new connection; the valid types are exactly the same as for the connection add command โœจ
  • con-name โ€” the name for the new connection. No stress, you can change it later in the editor ๐ŸŽ€
Also go peek at nm-settings-nmcli(5) for every single NetworkManager setting and property name plus their descriptions, and nmcli-examples(7) for sample editor sessions. iykyk ๐Ÿ“š

๐Ÿฆ‹ connection cluster: clone, delete, monitor

clone [--temporary] [id | uuid | path] ID new_name

Clone a connection, periodt. The connection you're cloning is identified by its name, UUID or D-Bus path. If ID is ambiguous, use a keyword โ€” id, uuid or path. (Again, connection show above explains those ID-specifying keywords.) new_name is the name of the new cloned connection. The new connection will be the exact copy except for the connection.id (which becomes new_name) and connection.uuid (which gets generated) properties. Everything else? Identical, no cap ๐Ÿ‘‘

The new connection profile gets saved as persistent unless you pass the --temporary option โ€” in which case the new profile won't exist after NetworkManager restart. Poof, gone ๐Ÿ’€

delete [id | uuid | path] ID...

Delete a configured connection. You identify the connection to delete by its name, UUID or D-Bus path. Ambiguous ID? Keyword time: id, uuid or path. (See connection show above for the description of the ID-specifying keywords.) You can list multiple IDs, hence the ... ๐Ÿซถ

Heads up: if the --wait option is not specified, the default timeout will be 10 seconds โณ

monitor [id | uuid | path] ID...

Monitor connection profile activity, bestie โ€” this command prints a line whenever the specified connection changes. The connection being monitored is identified by its name, UUID or D-Bus path, and if ID is ambiguous a keyword id, uuid or path works. (You already know where to read about those keywords: connection show above.)

If you specify none, it monitors all connection profiles. The command terminates when all monitored connections disappear ๐Ÿ˜ญ. And if you want to monitor connection creation, consider using the global monitor with the nmcli monitor command instead. Different vibe, different tool ๐ŸŒธ


๐ŸŒˆ reading from disk: reload & load

reload

Reload all connection files from disk. Here's the thing โ€” NetworkManager does not monitor changes to connections. So when you've made a change to those connection profiles on disk, you literally have to run this command to tell NetworkManager to re-read them. It's not being lazy, it just doesn't watch ๐Ÿ‘€

load filename...

Load/reload one or more connection files from disk. Use this after you've manually edited a connection file to make sure NetworkManager is aware of its latest state. Manual edits deserve a manual nudge ๐Ÿซก


๐Ÿ’œ VPN stuff: import & export

import [--temporary] type type file file

Import an external/foreign configuration as a NetworkManager connection profile ๐ŸŽ‰ The type of the input file is specified by the type option.

Only VPN configurations are supported at the moment. The configuration is imported by NetworkManager VPN plugins. The type values are the same as for the vpn-type option in nmcli connection add. Since VPN configurations are imported by VPN plugins, the proper VPN plugin has to be installed so that nmcli could import the data โ€” no plugin, no import, sorry not sorry ๐Ÿ™ˆ

The imported connection profile gets saved as persistent unless you use --temporary, in which case the new profile won't exist after NetworkManager restart. Same disappearing act as clone ๐Ÿ’€

export [id | uuid | path] ID [file]

Export a connection. That's it, that's the vibe โœจ

Only VPN connections are supported at the moment. A proper VPN plugin has to be installed so that nmcli could export a connection. And if no file is provided, the VPN configuration data will just be printed to standard output โ€” screen time instead of file time ๐Ÿ–จ๏ธ


๐Ÿ‘‘ glow-up time: migrate

migrate [--plugin plugin...] [id | uuid | path] [ID...]

Migrate connection profiles to a different settings plugin, such as keyfile (the default) or ifcfg-rh. It's giving rebrand, honestly ๐Ÿฆ‹

The connection to be migrated is identified by its name, UUID or D-Bus path. If ID is ambiguous, a keyword id, uuid or path can be used โ€” see connection show above for the description of the ID-specifying keywords.

If no connections are specified, the command acts on all available connections. Which means with no arguments at all, the command migrates every single connection profile to the keyfile plugin. All of them. The whole friend group ๐Ÿ”ฅ

And again: if the --wait option is not specified, the default timeout will be 10 seconds โณ

๐Ÿ’… DEVICE MANAGEMENT COMMANDS ๐Ÿ’…

Okay bestie, this is the whole โ€œtouch grass but for network interfacesโ€ part of nmcli โ€” you use it to show and manage network interfaces. No cap, itโ€™s giving main character energy for your NICs. โœจ

nmcli device {status | show | set | up | connect | reapply | modify | down | disconnect | delete | monitor | wifi | lldp | checkpoint} [ARGUMENTS...]

๐Ÿฉท status ๐Ÿฉท

Print status of devices. This is the default action if no command is specified to nmcli device, so if you just vibe in with nmcli device, this is what you get. ๐Ÿ’–

๐Ÿฆ‹ show [ifname] ๐Ÿฆ‹

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 โ€” yes, literally pass the ifname. ๐Ÿซถ

๐ŸŽ€ set [ifname] ifname [autoconnect {yes | no}] [managed [--permanent | --permanent-only] {yes | no | up | down | reset}] ๐ŸŽ€

Set device properties. Itโ€™s the โ€œadjust the settingsโ€ button, but make it terminal. ๐Ÿ’…

set [ifname] ifname [autoconnect {yes | no}]
[managed [--permanent | --permanent-only] {yes | no | up | down | reset}]

The managed property accepts a --permanent option to persist the managed state to disk, and not only in runtime. With --permanent-only, only the permanent managed state is set, and not the runtime managed state. The special values up and down can be used to set the administrative state of the device at the same time as the runtime managed state. The reset value clears the explicit managed setting, and with --permanent or --permanent-only it also removes the persisted managed setting. Lowkey thorough. ๐Ÿ˜ญ

๐ŸŒธ up ifname ๐ŸŒธ

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. Iconic teamwork, fr fr. โœจ

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" โ€” yes, that exact distinction matters. ๐Ÿซถ

If --wait option is not specified, the default timeout will be 90 seconds. So donโ€™t sit there confused if it takes a hot minute. โณ

๐Ÿงš connect ifname ๐Ÿงš

Alias for command up. Before version 1.34.0, up was not supported. Cute little version lore for you. ๐Ÿ’€

๐Ÿ’œ reapply ifname ๐Ÿ’œ

Attempt to update device with changes to the currently active connection made since it was last applied. Basically: โ€œhey, re-read the fit and see if it still slays.โ€ ๐Ÿ”ฅ

๐Ÿ‘‘ modify ifname {option value | [+|-]setting.property value}... ๐Ÿ‘‘

modify ifname {option value | [+|-]setting.property value}...

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 โ€” so this is temporary, bestie, not permanent. ๐Ÿ™ˆ

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. The way that some settings are locked in is so real. ๐Ÿ˜ญ

๐ŸŒˆ down ifname... ๐ŸŒˆ

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. So yes, the device can literally ghost you. ๐Ÿ’€

If --wait option is not specified, the default timeout will be 10 seconds. โฑ๏ธ

๐Ÿ“ disconnect ifname... ๐Ÿ“

Alias for command down. Before version 1.34.0, down was not supported. More version lore, iykyk. ๐Ÿงš

๐Ÿ’– delete ifname... ๐Ÿ’–

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 โ€” hardware said โ€œIโ€™m not going anywhere,โ€ periodt. ๐Ÿ’…

If --wait option is not specified, the default timeout will be 10 seconds. โณ

โญ monitor [ifname...] โญ

Monitor device activity. This command prints a line whenever the specified devices change state. Itโ€™s literally a little live feed for your device drama. ๐Ÿ‘€

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 ๐ŸŒธ

wifi [list [--rescan | auto | no | yes] [ifname ifname] [bssid BSSID]]

List available Wi-Fi access points. The ifname and bssid options can be used to list APs for a particular interface or with a specific BSSID, respectively. Very โ€œshow me the Wi-Fi menuโ€ energy. ๐Ÿ“

By default, nmcli ensures that the access point list is no older than 30 seconds and triggers a network scan if necessary. The --rescan can be used to either force or disable the scan regardless of how fresh the access point list is. So yes, you can make it scan on demand. โœจ

๐Ÿ’… wifi connect ๐Ÿ’…

wifi connect (B)SSID [password password] [wep-key-type {key | phrase}]
[ifname ifname] [bssid BSSID] [name name] [private {yes | no}]
[hidden {yes | no}]

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 โ€” literally the same vibe, but terminal. ๐Ÿซถ

If a connection for the network already exists, it is possible to bring up (activate) the existing profile as follows: nmcli con up id name. Note that only open, WEP and WPA-PSK networks are supported if no previous connection exists. It is also assumed that IP configuration is obtained via DHCP. No cap, thatโ€™s the fine print. ๐Ÿ˜ญ

If --wait option is not specified, the default timeout will be 90 seconds. โณ

Available options are:

  • password โ€” password for secured networks (WEP or WPA).
  • wep-key-type โ€” type of WEP secret, either key for ASCII/HEX key or phrase for passphrase.
  • ifname โ€” interface that will be used for activation.
  • bssid โ€” if specified, the created connection will be restricted just for the BSSID.
  • name โ€” if specified, the connection will use the name (else NM creates a name itself).
  • private โ€” if set to yes, the connection will only be visible to the user who created it. Otherwise, the connection is system-wide, which is the default.
  • hidden โ€” set to yes when connecting for the first time to an AP not broadcasting its SSID. Otherwise, the SSID would not be found and the connection attempt would fail. ๐Ÿ™ˆ

๐ŸŽ€ wifi hotspot ๐ŸŽ€

wifi hotspot [ifname ifname] [con-name name] [ssid SSID]
[band {a | bg | 6GHz}] [channel channel] [password password]

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 โ€” yes, you gotta turn it off manually, bestie. ๐Ÿ’…

Parameters of the hotspot can be influenced by the optional parameters:

  • ifname โ€” what Wi-Fi device is used.
  • con-name โ€” name of the created hotspot connection profile.
  • ssid โ€” SSID of the hotspot.
  • band โ€” Wi-Fi band to use.
  • channel โ€” Wi-Fi channel to use.
  • password โ€” password to use for the created hotspot. If not provided, nmcli will generate a password. The password is either WPA pre-shared key or WEP key. Note that --show-secrets global option can be used to print the hotspot password. It is useful especially when the password was generated. ๐Ÿ”ฅ

๐Ÿฆ‹ wifi rescan ๐Ÿฆ‹

wifi rescan [ifname ifname] [ssid SSID...]

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 ssid, it is possible to scan for a specific SSID, which is useful for APs with hidden SSIDs. You can provide multiple ssid parameters in order to scan more SSIDs. Obsessed with a manual refresh moment. โœจ

This command does not show the APs, use nmcli device wifi list for that. Donโ€™t expect this one to serve the list, itโ€™s just the scanner. ๐Ÿซถ

๐Ÿ’œ wifi show-password ๐Ÿ’œ

wifi show-password [ifname ifname]

Show the details of the active Wi-Fi networks, including the secrets. Yes, the secrets. Handle with care, bestie. ๐Ÿ”๐Ÿ˜ญ

๐Ÿงš lldp [list [ifname ifname]] ๐Ÿงš

Display information about neighboring devices learned through the Link Layer Discovery Protocol (LLDP). The ifname option can be used to list neighbors only for a given interface. The protocol must be enabled in the connection settings. Itโ€™s giving โ€œwhoโ€™s nearbyโ€ but for network devices. ๐Ÿ‘€

๐ŸŒŸ checkpoint [--timeout seconds] [ifname...] -- COMMAND... ๐ŸŒŸ

checkpoint [--timeout seconds] [ifname...] -- COMMAND...

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. Literally the โ€œundo buttonโ€ vibe for remote changes. ๐Ÿ˜ญโœจ

If a list of interface names is specified, the checkpoint is taken 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. Periodt. โณ


๐Ÿ•ต๏ธ SECRET AGENT ๐Ÿ•ต๏ธ

nmcli agent {secret | polkit | all}

Run nmcli as a NetworkManager secret agent, or polkit agent. Very spy-core, very โ€œIโ€™m the main character handling auth.โ€ ๐Ÿ’…

๐Ÿ” 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 --ask). However, you may find the command useful when you want to run a simple text based polkit agent and you do not have an agent of a desktop environment. Note that running this command makes nmcli handle all polkit requests, not only NetworkManager related ones, because only one polkit agent can run for the session. So yes, itโ€™s taking over the whole polkit situation. ๐Ÿ’€

๐ŸŒˆ all ๐ŸŒˆ

Runs nmcli as both NetworkManager secret and a polkit agent. Both jobs, one icon. โœจ

๐ŸŽจ COLORS ๐ŸŽจ

okay so bestie, implicit coloring can be disabled by an empty file at /etc/terminal-colors.d/nmcli.disable. That's the whole vibe check for turning the automatic colors off. See terminal-colors.d(5) for more details about colorization configuration. The logical color names supported by nmcli are:

  • connection-activated โ€” a connection that is active.
  • connection-activating โ€” a connection that is being activated.
  • connection-disconnecting โ€” a connection that is being disconnected.
  • connection-external โ€” a connection representing configuration created externally to NetworkManager.
  • connection-invisible โ€” a connection whose details the user is not permitted to see.
  • connection-deprecated โ€” a connection that uses deprecated settings. It might not be possible to activate it.
  • connectivity-full โ€” connectivity state when the Internet is reachable.
  • connectivity-limited โ€” connectivity state when only a local network is reachable.
  • connectivity-none โ€” connectivity state when the network is disconnected.
  • connectivity-portal โ€” connectivity state when a captive portal hijacked the connection.
  • connectivity-unknown โ€” connectivity state when a connectivity check didn't run.
  • device-activated โ€” a device that is connected.
  • device-activating โ€” a device that is being configured.
  • device-disconnected โ€” a device that is not connected.
  • device-external โ€” a device configured externally to NetworkManager.
  • device-firmware-missing โ€” warning of a missing device firmware.
  • device-plugin-missing โ€” warning of a missing device plugin.
  • device-unavailable โ€” a device that is not available for activation.
  • device-disabled โ€” a device is disabled by software or hardware kill switch.
  • manager-running โ€” notice that the NetworkManager daemon is available.
  • manager-starting โ€” notice that the NetworkManager daemon is being initially connected.
  • manager-stopped โ€” notice that the NetworkManager daemon is not available.
  • permission-auth โ€” an action that requires user authentication to get permission.
  • permission-no โ€” an action that is not permitted.
  • permission-yes โ€” an action that is permitted.
  • prompt โ€” prompt in interactive mode.
  • state-asleep โ€” indication that NetworkManager is in a suspended state.
  • state-connected-global โ€” indication that NetworkManager is connected to the Internet.
  • state-connected-local โ€” indication that NetworkManager is on a local network.
  • state-connected-site โ€” indication that NetworkManager is connected to networks other than the Internet.
  • state-connecting โ€” indication that NetworkManager is establishing a network connection.
  • state-disconnected โ€” indication that NetworkManager is disconnected from a network.
  • state-disconnecting โ€” indication that NetworkManager is being disconnected from a network.
  • wifi-signal-excellent โ€” a Wi-Fi network with an excellent signal level.
  • wifi-signal-fair โ€” a Wi-Fi network with a fair signal level.
  • wifi-signal-good โ€” a Wi-Fi network with a good signal level.
  • wifi-signal-poor โ€” a Wi-Fi network with a poor signal level.
  • wifi-signal-unknown โ€” a Wi-Fi network that hasn't been actually seen (a hidden AP).
  • wifi-deprecated โ€” a Wi-Fi network that might be impossible to connect to due to use of deprecated functionality.
  • disabled โ€” a property that is turned off.
  • enabled โ€” a property that is turned on.

๐ŸŒฑ ENVIRONMENT VARIABLES ๐ŸŒฑ

nmcli's behavior is affected by these environment variables, so likeโ€ฆ pay attention, bestie:

  • LC_ALL โ€” if set to a non-empty string value, it overrides the values of all the other internationalization variables.
  • LC_MESSAGES โ€” determines the locale to be used for internationalized messages.
  • LANG โ€” provides a default value for the internationalization variables that are unset or null.
  • NO_COLOR โ€” default to not producing colored and paged output. The --colors option, if used, takes precedence.
  • PAGER โ€” 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 LESS and LESSCHARSET appropriately for the less(1) pager, other pagers may or may not need extra configuration.

If unspecified, pager(1), less(1) and more(1) will be tried (in that order).

  • TERM โ€” terminal type. If dumb, nmcli will not use a pager or produce ANSI escape sequences for coloring.

Terminal types other than dumb are assumed to support ASCII escape sequences for setting the output color.


๐ŸŒ INTERNATIONALIZATION NOTES ๐ŸŒ

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. no cap, parsing localized output can absolutely be a little gremlin situation if you forget this.

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.


๐Ÿšช EXIT STATUS ๐Ÿšช

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 --wait option).
  • 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 --complete-args option, a file name is expected to follow.

โœจ EXAMPLES โœจ

Okay bestie, this is the part where we actually do stuff ๐Ÿ’… These are real, ready-to-paste nmcli moments. And if you're the kind of person who wants even MORE (icon behaviour, honestly), go peek at nmcli-examples(7). ๐ŸŽ€


nmcli -t -f RUNNING general

Tells you whether NetworkManager is running or not. Simple vibe check on the daemon itself. โœจ

nmcli -t -f STATE general

Shows the overall status of NetworkManager. Like the RUNNING check but it actually spills the tea about what state it's in. ๐Ÿซถ

nmcli radio wifi off

Switches Wi-Fi off. Bye bye, signal. ๐Ÿฆ‹

nmcli connection show

Lists all connections NetworkManager has. Your whole roster, no cap. ๐Ÿ‘‘

nmcli -p -m multiline -f all con show

Shows all configured connections in multi-line mode. Everything, spread out all pretty so your eyes don't cry. ๐Ÿ˜ญ

nmcli connection show --active

Lists all currently active connections. Only the ones that are actually out here living their lives. ๐Ÿ”ฅ

nmcli -f name,autoconnect c s

Shows all connection profile names and their auto-connect property. Ngl, this one's lowkey useful for a quick audit.

nmcli -p connection show "My default em1"

Shows details for "My default em1" connection profile. The -p is doing the pretty-print thing, it's giving polished. ๐Ÿ’…

nmcli --show-secrets connection show "My Home Wi-Fi"

Shows details for "My Home Wi-Fi" connection profile with all passwords. And like โ€” important caveat, bestie โ€” without --show-secrets option, secrets would not be displayed. So the passwords stay hidden unless you specifically ask. ๐Ÿ™ˆ

nmcli -f active connection show "My default em1"

Shows details for "My default em1" active connection, like IP, DHCP information, etc. The live tea, not the saved profile tea. ๐Ÿ“

nmcli -f profile con s "My wired connection"

Shows static configuration details of the connection profile with "My wired connection" name. This is the saved-config side of things.

nmcli -p con up "My wired connection" ifname eth0

Activates the connection profile with name "My wired connection" on interface eth0. The -p option makes nmcli show progress of the activation โ€” so you get the little progress moment instead of staring at a silent terminal. โญ

nmcli con up 6b028a27-6dc9-4411-9886-e9ad1dd43761 ap 00:3A:98:7C:42:D3

Connects the Wi-Fi connection with UUID 6b028a27-6dc9-4411-9886-e9ad1dd43761 to the AP with BSSID 00:3A:98:7C:42:D3. UUID and BSSID, extremely specific, we love a targeted operation. ๐ŸŽฏ

nmcli device status

Shows the status for all devices. The classic. If you learn one command, learn this one, fr fr.

nmcli dev down em2

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. So basically you unplugged its social life until you say otherwise. ๐Ÿ’€

nmcli -f GENERAL,WIFI-PROPERTIES dev show wlan0

Shows details for wlan0 interface; only GENERAL and WIFI-PROPERTIES sections will be shown. Filtered, focused, iconic. โœจ

nmcli -f CONNECTIONS device show wlp3s0

Shows all available connection profiles for your Wi-Fi interface wlp3s0.

nmcli dev wifi

Lists available Wi-Fi access points known to NetworkManager. Your neighbourhood, exposed. ๐ŸŒˆ

nmcli dev wifi con "Cafe Hotspot 1" password caffeine name "My cafe"

Creates a new connection named "My cafe" and then connects it to "Cafe Hotspot 1" SSID using password "caffeine". Aw bestie, 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. Don't make duplicate profiles, it's not the vibe. ๐Ÿซถ

nmcli -s dev wifi hotspot con-name QuickHotspot

Creates a hotspot profile and connects it. Prints the hotspot password the user should use to connect to the hotspot from other devices. The -s is how you actually get to see that password, so don't skip it. ๐Ÿ‘‘

nmcli dev modify em1 ipv4.method shared

Starts IPv4 connection sharing using em1 device. The sharing will be active until the device is disconnected. Temporary queen behaviour. โณ

nmcli dev modify em1 ipv6.address 2001:db8::a:bad:c0de

Temporarily adds an IP address to a device. The address will be removed when the same connection is activated again. So it's a for now address, not a forever address. ๐Ÿ’…

nmcli connection add type ethernet autoconnect no ifname eth0

Non-interactively adds an Ethernet connection tied to eth0 interface with automatic IP configuration (DHCP), and disables the connection's autoconnect flag. Scriptable, no prompts, chef's kiss. ๐ŸŽ€

nmcli c a ifname Maxipes-fik type vlan dev eth0 id 55

Non-interactively adds a VLAN connection with ID 55. The connection will use eth0 and the VLAN interface will be named Maxipes-fik. Yes, that name is real, and yes, it's iconic.

nmcli c a ifname eth0 type ethernet ipv4.method disabled ipv6.method link-local

Non-interactively adds a connection that will use eth0 Ethernet interface and only have an IPv6 link-local address configured. Efficient. Minimal. Modern. โœจ

nmcli connection edit ethernet-em1-2

Edits existing "ethernet-em1-2" connection in the interactive editor. Welcome to the editor, bestie, mind the prompts. ๐Ÿฆ‹

nmcli connection edit type ethernet con-name "yet another Ethernet connection"

Adds a new Ethernet connection in the interactive editor. Yes, "yet another" is literally part of the name here, copying it exactly.

nmcli con mod ethernet-2 connection.autoconnect no

Modifies 'autoconnect' property in the 'connection' setting of 'ethernet-2' connection.

nmcli con mod "Home Wi-Fi" wifi.mtu 1350

Modifies 'mtu' property in the 'wifi' setting of 'Home Wi-Fi' connection. Niche, but if you know, you know. iykyk. ๐Ÿ’œ

nmcli con mod em1-1 ipv4.method manual ipv4.addr "192.168.1.23/24 192.168.1.1, 10.10.1.5/8, 10.0.0.11"

Sets manual addressing and the addresses in em1-1 profile. Look at all those addresses, living in harmony. ๐ŸŒธ

nmcli con modify ABC +ipv4.dns 8.8.8.8

Appends a Google public DNS server to DNS servers in ABC profile. That + is doing the appending, don't lose it. ๐Ÿ”ฅ

nmcli con modify ABC -ipv4.addresses "192.168.100.25/24 192.168.1.1"

Removes the specified IP address from (static) profile ABC. Minus sign, subtract the address, very demure. ๐Ÿ’…

nmcli con import type openvpn file ~/Downloads/frootvpn.ovpn

Imports an OpenVPN configuration to NetworkManager. Fresh from your Downloads folder, blessed.

nmcli con export corp-vpnc /home/joe/corpvpn.conf

Exports NetworkManager VPN profile corp-vpnc as standard Cisco (vpnc) configuration. Sharing is caring, but check who you're sharing with. ๐ŸŽ€


๐ŸŒˆ NOTES ๐ŸŒˆ

Real talk: nmcli accepts abbreviations, as long as they are a unique prefix in the set of possible options. Cute and convenient, right? But โ€” as new options get added, these abbreviations are not guaranteed to stay unique. ๐Ÿ˜ญ So for scripting and long term compatibility it is therefore strongly advised to spell out the full option names. Future you will thank present you, no cap. โญ


๐Ÿ’€ BUGS ๐Ÿ’€

There are probably some bugs. Like, it's software, bestie. ๐Ÿ™ˆ If you find a bug, please report it to your distribution or upstream at https://gitlab.freedesktop.org/NetworkManager/NetworkManager. Reporting bugs is main character energy, honestly. ๐Ÿซถ


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

Go read these too, they're all part of the extended universe:


๐Ÿ’– That's the whole page, bestie! ๐Ÿ’– This one's NetworkManager 1.58.0, and the page itself is NMCLI(1) โ€” read it, love it, bookmark it, and go configure something iconic. Slay. ๐Ÿ‘‘โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from