NMCLI
Section: User Commands (1)
Updated: 6 September 2011
Index
Return to Main Contents
NAME
nmcli - command-line tool for controlling NetworkManager
SYNOPSIS
nmcli
[
OPTIONS ]
OBJECT {
COMMAND |
help }
OBJECT := {
nm | con | dev }
OPTIONS := {
-t[erse]
-p[retty]
-m[mode] tabular | multiline
-f[ields] <field1,field2,...> | all | common
-e[scape] yes | no
-v[ersion]
-h[elp]
}
DESCRIPTION
nmcli
is a command-line tool for controlling NetworkManager and getting its status.
It is not meant as a replacement of
nm-applet or other similar clients.
Rather it's a complementary utility to these programs.
The main
nmcli's usage is on servers, headless machines or just for
power users who prefer the command line.
The use cases comprise:
- ---
-
Initscripts: ifup/ifdown can utilize NetworkManager via nmcli instead of
having to manage connections itself and possibly interfere with NetworkManager.
- ---
-
Servers, headless machines: No GUI is available; then nmcli can be used
to activate/deactivate connections. However, if a connection requires a secret
to activate and if that secret is not stored at the system level, nmcli
will not be able to activate it; it is currently unable to supply the needed
secrets to NetworkManager.
- ---
-
User sessions: nmcli can be used activate/deactivate connections from the
command line, but a full NetworkManager client (like nm-applet) is used
for supplying secrets not stored at the system level. Keyring dialogs and
password prompts may appear if this happens.
OPTIONS
- -t, --terse
-
Output is terse. This mode is designed and suitable for computer (script)
processing.
- -p, --pretty
-
Output is pretty. This causes nmcli to produce easy readable outputs
for humans, i.e. values are aligned, headers are printed, etc.
- -m, --mode tabular | multiline
-
Switch between tabular and multiline output.
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. Currenly, they are:
'nmcli con list id|uuid <name>'
'nmcli dev list'
tabular - Output is a table where each line describes a single entry.
Columns define particular properties of the entry.
multiline - Each entry comprises more lines, each property on its own line.
The values are prefixed with the property name.
- -f, --fields <field1,field2,...> | all | common
-
This option is used to specify what fields (column names) should be printed.
Valid field names differ for specific commands. List available fields by
providing an invalid value to the --fields option.
all is used to print all valid field values of the command.
common is used to print common field values of the command.
If omitted, default is common.
The option is mandatory when --terse is used. In this case, generic
values all and common cannot be used. (This is to maintain
compatibility when new fields are added in the future).
- -e, --escape yes | no
-
Whether to escape ':' and '\' characters in terse tabular mode. The escape
character is '\'.
If omitted, default is yes.
- -v, --version
-
Show nmcli version.
- -h, --help
-
Print help information.
OBJECT
- nm
-
NetworkManager
Use this object to inquire and change state of NetworkManager.
COMMAND := { status | enable | sleep | wifi | wwan }
-
- status
-
Show overall status of NetworkManager. This is the default action, when no
command is provided to nm object.
Reference to D-Bus:
No simple reference.
- enable [true|false]
-
Get networking-enabled status or enable/disable networking by NetworkManager.
All interfaces managed by NetworkManager are deactivated when networking has
been disabled.
Reference to D-Bus:
interface: org.freedesktop.NetworkManager
method: Enable
arguments: TRUE or FALSE
- sleep [true|false]
-
Get sleep status or put to sleep/awake NetworkManager. All interfaces managed by NetworkManager
are deactivated when it falls asleep. This command is not meant for user to enable/disable
networking, use enable for that. D-Bus Sleep method is designed
to put NetworkManager to sleep or awake for suspending/resuming computer.
Reference to D-Bus:
interface: org.freedesktop.NetworkManager
method: Sleep
arguments: TRUE or FALSE
- wifi [on|off]
-
Inquire or set status of WiFi in NetworkManager. Without any further argument,
WiFi status is printed; on enables WiFi; off disables WiFi.
Reference to D-Bus:
No simple reference.
- wwan [on|off]
-
Inquire or set status of WWAN in NetworkManager. Without any further argument,
WWAN status is printed; on enables WWAN; off disables WWAN.
Reference to D-Bus:
No simple reference.
- con
-
Connections
Get information about NetworkManager's connections.
COMMAND := { list | status | up | down | delete }
-
- list [id <id> | uuid <id>]
-
List configured connections. Without a parameter, all connections
are listed. In order to get connection details, id with connection's
name or uuid with connection's UUID shall be specified. When no command
is given to the con object, the default action is 'nmcli con list'.
Reference to D-Bus:
No simple reference.
- status
-
Print status of active connections.
Reference to D-Bus:
No simple reference.
- up id <id> | uuid <id> [iface <iface>] [ap <BSSID>] [--nowait] [--timeout <timeout>]
-
Activate a connection. The connection is identified by its name using id
or UUID using uuid. For requiring particular device to activate
the connection on, iface option with interface name should be given.
ap option can further concretize what AP should be used in case of WiFi
connection. --nowait option causes nmcli to exit immediately and
not to wait for command completion. --timeout option provides a means
to specify how long to wait for operation completion.
Reference to D-Bus:
interface: org.freedesktop.NetworkManager
method: ActivateConnection
arguments: according to arguments
- down id <id> | uuid <id>
-
Deactivate a connection.
The connection is identified by its name using id
or UUID using uuid.
Reference to D-Bus:
interface: org.freedesktop.NetworkManager
method: DeactivateConnection
arguments: according to arguments
- delete id <id> | uuid <id>
-
Delete a configured connection. The connection to delete is specified with
id (connection name) or uuid (connection UUID).
Reference to D-Bus:
interface: org.freedesktop.NetworkManager.Settings.Connection
method: Delete
arguments: none
- dev
-
Devices
Get information about devices.
COMMAND := { status | list | disconnect | wifi }
-
- status
-
Print status of devices. This is the default action, when no command
is specified to dev object.
Reference to D-Bus:
No simple reference.
- list [iface <iface>]
-
Get detailed information about devices. Without an argument, all devices are
examined. To get information for a specific device, iface argument
with the interface name should be provided.
Reference to D-Bus:
No simple reference.
- disconnect iface <iface> [--nowait] [--timeout <timeout>]
-
Disconnect a device and prevent the device from automatically activating further
connections without user/manual intervention. --nowait option causes
nmcli to exit immediately and not to wait for command completion.
--timeout option provides a means to specify how long to wait for
operation completion.
Reference to D-Bus:
interface: org.freedesktop.NetworkManager.Device
method: Disconnect
arguments: none
- wifi [list [iface <iface>] [bssid <BSSID>]]
-
List available WiFi access points. iface and bssid options
can be used to get just APs for particular interface or specific AP,
respectively.
Reference to D-Bus:
No simple reference.
ENVIRONMENT VARIABLES
nmcli's behavior is affected by the following environment variables.
- LC_ALL
-
If set to a non-empty string value, override the values of all the other
internationalization variables.
- LC_MESSAGES
-
Determines the locale to be used for internationalised messages.
- LANG
-
Provides a default value for the internationalization variables that are unset
or null.
Notes about localization:
Be aware that nmcli is localized and that's why the output depends on
your environment. It's important to realize that 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.
EXIT STATUS
nmcli exits with status 0 if it succeeds, a value greater than 0 is returned if errors occur.
- 0
-
Success - indicates the operation succeeded
- 1
-
Unknown or unspecified error
- 2
-
Invalid user input, wrong nmcli invocation
- 3
-
Timeout expired (see commands with --timeout option)
- 4
-
Connection activation failed
- 5
-
Connection deactivation failed
- 6
-
Disconnecting device failed
BUGS
There are probably some. If you find a bug, please report to
https://bugzilla.gnome.org/ - product NetworkManager.
SEE ALSO
nm-tool(1),
nm-online(1),
NetworkManager(8).
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- OBJECT
-
- COMMAND := { status | enable | sleep | wifi | wwan }
-
- COMMAND := { list | status | up | down | delete }
-
- COMMAND := { status | list | disconnect | wifi }
-
- ENVIRONMENT VARIABLES
-
- EXIT STATUS
-
- BUGS
-
- SEE ALSO
-
© Andrew Scott 2006 -
2024,
All Rights Reserved