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
nmcliinstead of managing network connections by hand.nmclisupports 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 โ checkNetworkManager(8)for all the deets on those. ๐ซถ - Servers, headless machines, and terminals:
nmclilets 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 optionnmcliwill 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).yesenables colors,nodisables them,autoonly produces colors when standard output is directed to a terminal. the default value isauto. โจ
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,nmcliwill 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 isyes.-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--fieldsoption an invalid value and she'll tell you. ๐allprints all valid field values of the command.commonprints common field values of the command. if omitted, default iscommon.-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 IDnmcli device show
-p,--prettyโ output is pretty. this makesnmcliproduce easily readable output for humans, i.e. values are aligned, headers are printed, etc. ๐-s,--show-secretsโ with this optionnmcliwill 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. makesconnection addandconnection modifycommands accept and produce connection data via standard input/output. ordinarily,nmcliwould be communicating with the NetworkManager service.
the connection data format (keyfile) is described in the nm-settings-keyfile(5) manual. ๐
-v,--versionโ shownmcliversion. ๐โโ๏ธ-w,--wait secondsโ sets a timeout period for whichnmcliwill 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 fornmcli 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, provideleveland/ordomainparameters. seeNetworkManager.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 sendingSIGHUPto 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 theNetworkManager.confconfiguration from disk. note that this does not include connections, which can be reloaded throughnmcli connection reloadinstead.dns-rcโ update DNS configuration, which usually involves writing/etc/resolv.confanew. this is equivalent to sending theSIGUSR1signal to the NetworkManager process.dns-fullโ restart the DNS plugin. this is for example useful when using thednsmasqplugin, 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 optionalcheckargument 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;onenables Wi-Fi;offdisables 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;onenables mobile broadband,offdisables 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/numor justnum.apathโ the ID denotes a D-Bus active connection path in the format of/org/freedesktop/NetworkManager/ActiveConnection/numor justnum.
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 tonmcli connection, the default action isnmcli 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:
6lowpan802-11-olpc-mesh(aliasolpc-mesh)802-11-wireless(aliaswifi)802-3-ethernet(aliasethernet)adslbluetoothbondbond-slave(deprecated for ethernet with controller)bridgebridge-slave(deprecated for ethernet with controller)cdmadummygenericgsmhsrinfinibandip-tunnelipvlanloopbackmacsecmacvlanolpc-meshovs-bridgeovs-interfaceovs-portpppoeteamteam-slave(deprecated for ethernet with controller)tunvethvlanvpnvrfvxlanwifi-p2pwimaxwireguardwpan
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 ofnmcli.
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 theconnection addcommand โจcon-nameโ the name for the new connection. No stress, you can change it later in the editor ๐
Also go peek atnm-settings-nmcli(5)for every single NetworkManager setting and property name plus their descriptions, andnmcli-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--waitoption is not specified, the default timeout will be10seconds โณ
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--waitoption is not specified, the default timeout will be10seconds โณ
๐ 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, eitherkeyfor ASCII/HEX key orphrasefor 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 toyes, the connection will only be visible to the user who created it. Otherwise, the connection is system-wide, which is the default.hiddenโ set toyeswhen 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,nmcliwill generate a password. The password is either WPA pre-shared key or WEP key. Note that--show-secretsglobal 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--colorsoption, 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. Ifdumb,nmcliwill 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, wrongnmcliinvocation.3โ Timeout expired (see--waitoption).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-argsoption, 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:
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)
๐ 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
- centos-stream 10: NetworkManager 1:1.58.0-1.el10 ยท GPL-2.0-or-later AND LGPL-2.1-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms