NMCLI(1) | General Commands Manual | NMCLI(1) |
nmcli - command-line tool for controlling NetworkManager
nmcli [OPTIONS...] {help | general | networking | radio | connection | device | agent | monitor} [COMMAND] [ARGUMENTS...]
nmcli is a command-line tool for controlling NetworkManager and reporting network status. It can be utilized as a replacement for nm-applet or other graphical clients. nmcli is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.
Typical uses include:
-t | --terse
-p | --pretty
-m | --mode {tabular | multiline}
tabular
multiline
If omitted, default is tabular for most commands. For the commands producing more structured information, that cannot be displayed on a single line, default is multiline. Currently, they are:
-c | --colors {yes | no | 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 supported by nmcli.
-f | --fields {field1,field2... | all | common}
If omitted, default is common.
-g | --get-values {field1,field2... | all | common}
If a section is specified instead of a field, the section name will be printed followed by colon separated values of the fields belonging to that section, all on the same line.
-e | --escape {yes | no}
If omitted, default is yes.
-a | --ask
-s | --show-secrets
-w | --wait seconds
Specifying a value of 0 instructs nmcli not to wait but to exit immediately with a status of success. The default value depends on the executed command.
--complete-args
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.
-v | --version
-h | --help
nmcli general {status | hostname | permissions | logging} [ARGUMENTS...]
Use this command to show NetworkManager status and permissions. You can also get and change system hostname, as well as NetworkManager logging level and domains.
status
hostname [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 /etc/hostname file in most distributions. For example, systemd-hostnamed service uses the term "static" hostname and it only reads the /etc/hostname file when it starts.
permissions
logging [level level] [domains domains...]
nmcli networking {on | off | connectivity} [ARGUMENTS...]
Query NetworkManager networking status, enable and disable networking.
on, off
connectivity [check]
Possible states are:
none
portal
limited
full
unknown
nmcli radio {all | wifi | wwan} [ARGUMENTS...]
Show radio switches status, or enable and disable the switches.
wifi [on | off]
wwan [on | off]
all [on | off]
nmcli monitor
Observe NetworkManager activity. Watches for changes in connectivity state, devices or connection profiles.
See also nmcli connection monitor and nmcli device monitor to watch for changes in certain devices or connections.
nmcli connection {show | up | down | modify | add | edit | clone | delete | monitor | reload | load | import | export} [ARGUMENTS...]
NetworkManager stores all network configuration as "connections", which are collections of data (Layer2 details, IP addressing, etc.) that describe how to create or connect to a network. A connection is "active" when a device uses that connection's configuration to create or connect to a network. There may be multiple connections that apply to a device, but only one of them can be active on that device at any given time. The additional connections can be used to allow quick switching between different networks and configurations.
Consider a machine which is usually connected to a DHCP-enabled network, but sometimes connected to a testing network which uses static IP addressing. Instead of manually reconfiguring eth0 each time the network is changed, the settings can be saved as two connections which both apply to eth0, one for DHCP (called default) and one with the static addressing details (called testing). When connected to the DHCP-enabled network the user would run nmcli con up default , and when connected to the static network the user would run nmcli con up testing.
show [--active] [--order [+-]category:...]
The --order option can be used to get custom ordering of connections. The connections can be ordered by active status (active), name (name), type (type) or D-Bus path (path). If connections are equal according to a sort order category, an additional category can be specified. The default sorting order is equivalent to --order active:name:path. + or no prefix means sorting in ascending order (alphabetically or in numbers), - means reverse (descending) order. The category names can be abbreviated (e.g. --order -a:na).
show [--active] [id | uuid | path | apath] ID...
id, uuid, path and apath keywords can be used if ID is ambiguous. Optional ID-specifying keywords are:
id
uuid
path
apath
It is possible to filter the output using the global --fields option. Use the following values:
profile
active
You can also specify particular fields. For static configuration, use setting and property names as described in nm-settings(5) manual page. For active data use GENERAL, IP4, DHCP4, IP6, DHCP6, VPN.
When no command is given to the nmcli connection, the default action is nmcli connection show.
up [id | uuid | path] ID [ifname ifname] [ap BSSID] [passwd-file file]
If --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
ap
passwd-file
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 is not given, nmcli will ask for it when run with --ask. If --ask was not passed, NetworkManager can ask another secret agent that may be running (typically a GUI secret agent, such as nm-applet or gnome-shell).
down [id | uuid | path | apath] ID...
Be aware that this command deactivates the specified active connection, but the device on which the connection was active, is still ready to connect and will perform auto-activation by looking for a suitable connection that has the 'autoconnect' flag set. This includes the just deactivated connection. So if the connection is set to auto-connect, it will be automatically started on the disconnected device again.
In most cases you may want to use device disconnect 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 --wait option is not specified, the default timeout will be 10 seconds.
modify [--temporary] [id | uuid | path] ID {option value | [+|-]setting.property value}...
To set the property just specify the property name followed by the value. An empty value ("") removes the property value.
In addition to the properties, you can also use short names for some of the properties. Consult the PROPERTY ALIASES section for details.
If you want to append an item to the existing value, use + prefix for the property name. If you want to remove just one item from container-type property, use - prefix for the property name and specify a value or an zero-based index of the item to remove (or option name for properties with named options) as value. The + and - modifies only have a real effect for multi-value (container) properties like ipv4.dns, ipv4.addresses, bond.options, etc.
See nm-settings(5) for complete reference of setting and property names, their descriptions and default values. The setting and property can be abbreviated provided they are unique.
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.
add [save {yes | no}] {option value | [+|-]setting.property value}...
You need to describe the newly created connections with the property and value pairs. See nm-settings(5) for the complete reference. You can also use the aliases described in PROPERTY ALIASES section. The syntax is the same as of the nmcli connection modify command.
To construct a meaningful connection you at the very least need to set the connection.type property (or use the type alias) to one of known NetworkManager connection types:
The most typical uses are described in the EXAMPLES section.
Aside from the properties and values two special options are accepted:
save
--
edit {[id | uuid | path] ID | [type type] [con-name name] }
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 description of the ID-specifying keywords. Not providing an ID means that a new connection will be added.
The interactive editor will guide you through the connection editing and allow you to change connection parameters according to your needs by means of a simple menu-driven interface. The editor indicates what settings and properties can be modified and provides in-line help.
Available options:
type
con-name
See also nm-settings(5) for all NetworkManager settings and property names, and their descriptions; and nmcli-examples(7) for sample editor sessions.
clone [--temporary] [id | uuid | path] ID new_name
The new connection profile will be saved as persistent unless --temporary option is specified, in which case the new profile won't exist after NetworkManager restart.
delete [id | uuid | path] ID...
If --wait option is not specified, the default timeout will be 10 seconds.
monitor [id | uuid | path] ID...
Monitors all connection profiles in case none is specified. The command terminates when all monitored connections disappear. If you want to monitor connection creation consider using the global monitor with nmcli monitor command.
reload
load filename...
import [--temporary] type type file file
Only VPN configurations are supported at the moment. The configuration is imported by NetworkManager VPN plugins. type values are the same as for vpn-type option in nmcli connection add. VPN configurations are imported by VPN plugins. Therefore the proper VPN plugin has to be installed so that nmcli could import the data.
The imported connection profile will be saved as persistent unless --temporary option is specified, in which case the new profile won't exist after NetworkManager restart.
export [id | uuid | path] ID [file]
Only VPN connections are supported at the moment. A proper VPN plugin has to be installed so that nmcli could export a connection. If no file is provided, the VPN configuration data will be printed to standard output.
nmcli device {status | show | set | connect | reapply | modify | disconnect | delete | monitor | wifi | lldp} [ARGUMENTS...]
Show and manage network interfaces.
status
This is the default action if no command is specified to nmcli device.
show [ifname]
set [ifname] ifname [autoconnect {yes | no}] [managed {yes | no}]
connect ifname
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 connect "$DEVICE"
If --wait option is not specified, the default timeout will be 90 seconds.
reapply ifname
modify ifname {option value | [+|-]setting.property value}...
This command lets you do temporary changes to a configuration active on a particular device. The changes are not preserved in the connection profile.
See nm-settings(5) for the list of available properties. Please note that some properties can't be changed on an already connected device.
You can also use the aliases described in PROPERTY ALIASES section. The syntax is the same as of the nmcli connection modify command.
disconnect ifname...
If --wait option is not specified, the default timeout will be 10 seconds.
delete ifname...
If --wait option is not specified, the default timeout will be 10 seconds.
monitor [ifname...]
Monitors all devices in case no interface is specified. The monitor terminates when all specified devices disappear. If you want to monitor device addition consider using the global monitor with nmcli monitor command.
wifi [list [--rescan | auto | no | yes] [ifname ifname] [bssid BSSID]]
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.
wifi connect (B)SSID [password password] [wep-key-type {key | phrase}] [ifname ifname] [bssid BSSID] [name name] [private {yes | no}] [hidden {yes | no}]
If --wait option is not specified, the default timeout will be 90 seconds.
Available options are:
password
wep-key-type
ifname
bssid
name
private
hidden
wifi hotspot [ifname ifname] [con-name name] [ssid SSID] [band {a | bg}] [channel channel] [password password]
Parameters of the hotspot can be influenced by the optional parameters:
ifname
con-name
ssid
band
channel
password
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 [ifname ifname] [ssid SSID...]
This command does not show the APs, use nmcli device wifi list for that.
lldp [list [ifname ifname]]
nmcli agent {secret | polkit | all}
Run nmcli as a NetworkManager secret agent, or polkit agent.
secret
polkit
all
Apart from the property-value pairs, connection add, connection modify and device modify also accept short forms of some properties. They exist for convenience. Some aliases can affect multiple connection properties at once.
The overview of the aliases is below. An actual connection type is used to disambiguate these options from the options of the same name that are valid for multiple connection types (such as mtu).
Table 1. Options for all connections
Alias | Property | Note |
type | connection.type | This alias also accepts values of bond-slave, team-slave and bridge-slave. They create ethernet connection profiles. Their use is discouraged in favor of using a specific type with master option. |
con-name | connection.id | When not provided a default name is generated: <type>[-<ifname>][-<num>]). |
autoconnect | connection.autoconnect | |
ifname | connection.interface-name | A value of * will be interpreted as no value, making the connection profile interface-independent. Note: use quotes around * to suppress shell expansion. For bond, team and bridge connections a default name will be generated if not set. |
master | connection.master | Value specified here will be canonicalized. It can be prefixed with ifname/, uuid/ or id/ to disambiguate it. |
slave-type | connection.slave-type |
Table 2. PPPoE options
Alias | Property |
username | pppoe.username |
password | pppoe.password |
service | pppoe.service |
parent | pppoe.parent |
Table 3. Wired Ethernet options
Alias | Property |
mtu | wired.mtu |
mac | wired.mac-address |
cloned-mac | wired.cloned-mac-address |
Table 4. Infiniband options
Alias | Property |
mtu | infiniband.mtu |
mac | infiniband.mac-address |
transport-mode | infiniband.transport-mode |
parent | infiniband.parent |
p-key | infiniband.p-key |
Table 5. Wi-Fi options
Alias | Property |
ssid | wireless.ssid |
mode | wireless.mode |
mtu | wireless.mtu |
mac | wireless.mac-address |
cloned-mac | wireless.cloned-mac-address |
Table 6. WiMax options
Alias | Property |
nsp | wimax.network-name |
mac | wimax.mac-address |
Table 7. GSM options
Alias | Property |
apn | gsm.apn |
user | gsm.username |
password | gsm.password |
Table 8. CDMA options
Alias | Property |
user | cdma.username |
password | cdma.password |
Table 9. Bluetooth options
Alias | Property | Note |
addr | bluetooth.bdaddr | |
bt-type | bluetooth.type | Apart from the usual panu, nap and dun options, the values of dun-gsm and dun-cdma can be used for compatibility with older versions. They are equivalent to using dun and setting appropriate gsm.* or cdma.* properties. |
Table 10. VLAN options
Alias | Property |
dev | vlan.parent |
id | vlan.id |
flags | vlan.flags |
ingress | vlan.ingress-priority-map |
egress | vlan.egress-priority-map |
Table 11. Bonding options
Alias | Property | Note |
mode | bond.options | Setting each of these adds the option to bond.options property. It's equivalent to the +bond.options 'option=value' syntax. |
primary | ||
miimon | ||
downdelay | ||
updelay | ||
arp-interval | ||
arp-ip-target | ||
lacp-rate |
Table 12. Team options
Alias | Property | Note |
config | team.config | Either a filename or a team configuration in JSON format. To enforce one or the other, the value can be prefixed with "file://" or "json://". |
Table 13. Team port options
Alias | Property | Note |
config | team-port.config | Either a filename or a team configuration in JSON format. To enforce one or the other, the value can be prefixed with "file://" or "json://". |
Table 14. Bridge options
Alias | Property |
stp | bridge.stp |
priority | bridge.priority |
forward-delay | bridge.forward-delay |
hello-time | bridge.hello-time |
max-age | bridge.max-age |
ageing-time | bridge.ageing-time |
group-forward-mask | bridge.group-forward-mask |
multicast-snooping | bridge.multicast-snooping |
mac | bridge.mac-address |
priority | bridge-port.priority |
path-cost | bridge-port.path-cost |
hairpin | bridge-port.hairpin-mode |
Table 15. VPN options
Alias | Property |
vpn-type | vpn.service-type |
user | vpn.user-name |
Table 16. OLPC Mesh options
Alias | Property |
ssid | olpc-mesh.ssid |
channel | olpc-mesh.channel |
dhcp-anycast | olpc-mesh.dhcp-anycast-address |
Table 17. ADSL options
Alias | Property |
username | adsl.username |
protocol | adsl.protocol |
password | adsl.password |
encapsulation | adsl.encapsulation |
Table 18. MACVLAN options
Alias | Property |
dev | macvlan.parent |
mode | macvlan.mode |
tap | macvlan.tap |
Table 19. MACsec options
Alias | Property |
dev | macsec.parent |
mode | macsec.mode |
encrypt | macsec.encrypt |
cak | macsec.cak |
ckn | macsec.ckn |
port | macsec.port |
Table 20. VxLAN options
Alias | Property |
id | vxlan.id |
remote | vxlan.remote |
dev | vxlan.parent |
local | vxlan.local |
source-port-min | vxlan.source-port-min |
source-port-max | vxlan.source-port-max |
destination-port | vxlan.destination-port |
Table 21. Tun options
Alias | Property |
mode | tun.mode |
owner | tun.owner |
group | tun.group |
pi | tun.pi |
vnet-hdr | tun.vnet-hdr |
multi-queue | tun.multi-queue |
Table 22. IP tunneling options
Alias | Property |
mode | ip-tunnel.mode |
local | ip-tunnel.local |
remote | ip-tunnel.remote |
dev | ip-tunnel.parent |
Table 23. WPAN options
Alias | Property |
mac | wpan.mac |
short-addr | wpan.short-addr |
pan-id | wpan.pan-id |
Table 24. 6LoWPAN options
Alias | Property |
dev | 6lowpan.parent |
Table 25. IPv4 options
Alias | Property | Note |
ip4 | ipv4.addresses ipv4.method | The alias is equivalent to the +ipv4.addresses syntax and also sets ipv4.method to manual. It can be specified multiple times. |
gw4 | ipv4.gateway |
Table 26. IPv6 options
Alias | Property | Note |
ip6 | ipv6.addresses ipv6.method | The alias is equivalent to the +ipv6.addresses syntax and also sets ipv6.method to manual. It can be specified multiple times. |
gw6 | ipv6.gateway |
Table 27. Proxy options
Alias | Property | Note |
method | proxy.method | |
browser-only | proxy.browser-only | |
pac-url | proxy.pac-url | |
pac-script | proxy.pac-script | Read the JavaScript PAC (proxy auto-config) script from file or pass it directly on the command line. Prefix the value with "file://" or "js://" to force one or the other. |
Implicit coloring can be disabled by an empty file
/etc/terminal-colors.d/nmcli.disable.
See terminal-colors.d(5) for more details about colorization configuration. The logical color names supported by nmcli are:
connection-activated
connection-activating
connection-disconnecting
connection-invisible
connectivity-full
connectivity-limited
connectivity-none
connectivity-portal
connectivity-unknown
device-activated
device-activating
device-disconnected
device-firmware-missing
device-plugin-missing
device-unavailable
manager-running
manager-starting
manager-stopped
permission-auth
permission-no
permission-yes
prompt
state-asleep
state-connected-global
state-connected-local
state-connected-site
state-connecting
state-disconnected
state-disconnecting
wifi-signal-excellent
wifi-signal-fair
wifi-signal-good
wifi-signal-poor
wifi-signal-unknown
disabled
enabled
nmcli's behavior is affected by the following environment variables.
LC_ALL
LC_MESSAGES
LANG
Be aware that nmcli is localized and that is why the output depends on your environment. This is important to realize especially when you parse the output.
Call nmcli as LC_ALL=C nmcli to be sure the locale is set to C while executing in a script.
LC_ALL, LC_MESSAGES, LANG variables specify the LC_MESSAGES locale category (in that order), which determines the language that nmcli uses for messages. The C locale is used if none of these variables are set, and this locale uses English messages.
nmcli exits with status 0 if it succeeds, a value greater than 0 is returned if an error occurs.
0
1
2
3
4
5
6
7
8
10
65
This section presents various examples of nmcli usage. If you want even more, please refer to nmcli-examples(7) manual page.
nmcli -t -f RUNNING general
nmcli -t -f STATE general
nmcli radio wifi off
nmcli connection show
nmcli -p -m multiline -f all con show
nmcli connection show --active
nmcli -f name,autoconnect c s
nmcli -p connection show "My default em1"
nmcli --show-secrets connection show "My Home WiFi"
nmcli -f active connection show "My default em1"
nmcli -f profile con s "My wired connection"
nmcli -p con up "My wired connection" ifname eth0
nmcli con up 6b028a27-6dc9-4411-9886-e9ad1dd43761 ap 00:3A:98:7C:42:D3
nmcli device status
nmcli dev disconnect em2
nmcli -f GENERAL,WIFI-PROPERTIES dev show wlan0
nmcli -f CONNECTIONS device show wlp3s0
nmcli dev wifi
nmcli dev wifi con "Cafe Hotspot 1" password caffeine name "My cafe"
nmcli -s dev wifi hotspot con-name QuickHotspot
nmcli dev modify em1 ipv4.method shared
nmcli dev modify em1 ipv6.address 2001:db8::a:bad:c0de
nmcli connection add type ethernet autoconnect no ifname eth0
nmcli c a ifname Maxipes-fik type vlan dev eth0 id 55
nmcli c a ifname eth0 type ethernet ipv4.method disabled ipv6.method link-local
nmcli connection edit ethernet-em1-2
nmcli connection edit type ethernet con-name "yet another Ethernet connection"
nmcli con mod ethernet-2 connection.autoconnect no
nmcli con mod "Home Wi-Fi" wifi.mtu 1350
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"
nmcli con modify ABC +ipv4.dns 8.8.8.8
nmcli con modify ABC -ipv4.addresses "192.168.100.25/24 192.168.1.1"
nmcli con import type openvpn file ~/Downloads/frootvpn.ovpn
nmcli con export corp-vpnc /home/joe/corpvpn.conf
nmcli accepts abbreviations, as long as they are a unique prefix in the set of possible options. As new options get added, these abbreviations are not guaranteed to stay unique. For scripting and long term compatibility it is therefore strongly advised to spell out the full option names.
There are probably some bugs. If you find a bug, please report it to https://bugzilla.gnome.org/ — product NetworkManager.
nmcli-examples(7), nm-online(1), NetworkManager(8), NetworkManager.conf(5), nm-settings(5), nm-applet(1), nm-connection-editor(1), terminal-colors.d(5).
NetworkManager 1.14.6 |