nmcli
Control NetworkManager from the command line
TLDR
View documentation for managing network interfaces and establishing new Wi-Fi connections
View documentation for managing network connections
View documentation for running nmcli as a NetworkManager secret/polkit agent
View documentation for managing general settings of NetworkManager
View documentation for NetworkManager's activity monitor
View documentation for enabling/disabling and checking the status of networking
View documentation for managing radio switches
SYNOPSIS
nmcli [OPTIONS] OBJECT { COMMAND | help }
Common Objects:
general
networking
radio
connection (or con)
device (or dev)
agent
monitor
Example: nmcli connection show
Example: nmcli device wifi connect SSID password WPA_PASSPHRASE
PARAMETERS
--terse, -t
Output results in a terse (script-friendly) format with fields separated by colons.
--fields
Specify which fields to output. Use 'all' for all fields, or a comma-separated list of field names. Only effective with --terse or --pretty.
--expanded, -e
Output results in an expanded format, where each field is on its own line.
--colors
Whether to use colors in the output. 'auto', 'always', or 'never'.
--pretty, -p
Pretty print output. Attempts to use human-readable formatting and aligned columns.
--width
Set output width for tables. Useful with --pretty.
--version, -v
Show nmcli version and exit.
--help, -h
Show nmcli help and exit. Can be used with an object or command for specific help (e.g., 'nmcli connection help').
--ask, -a
Ask for missing parameters. If a parameter is missing (e.g., Wi-Fi password), nmcli will prompt the user for it.
DESCRIPTION
The nmcli command-line utility is a powerful client for NetworkManager, allowing users to control network settings directly from the terminal. It provides a comprehensive set of functionalities for managing network connections and devices.
With nmcli, you can perform various tasks such as displaying network status, activating and deactivating network connections, creating new connections (e.g., Wi-Fi, Ethernet, VPN), editing existing ones, and deleting them. It also allows for device management, including bringing interfaces up or down, scanning for Wi-Fi networks, and managing network radio states.
nmcli is particularly useful for scripting, server environments, or for users who prefer a command-line interface over graphical tools. Its versatile options and subcommands make it an essential tool for network administration on Linux systems where NetworkManager is in use.
CAVEATS
nmcli requires the NetworkManager service to be running to function correctly. Most operations, especially those that modify system network configurations, require root privileges or membership in specific user groups (e.g., 'nmcli-l' for limited users, or typically sudo/root for full control). The default output can be verbose; using options like --terse and --fields is highly recommended for scripting.
CORE OBJECTS
nmcli organizes its functionalities around several core objects. These objects represent different aspects of network management:
- general: Overall NetworkManager status.
- networking: Global networking enablement/disablement.
- radio: Control Wi-Fi and WWAN radio states.
- connection: Manage network connections (profiles) including add, modify, delete, activate, deactivate.
- device: Manage network hardware devices, show status, connect to Wi-Fi.
- agent: Manage NetworkManager secret agents.
- monitor: Monitor NetworkManager events.
SCRIPTING AND OUTPUT
For scripting purposes, nmcli's output can be tailored using the --terse (-t) and --fields (-f) options. This allows for precise parsing of command output, making it reliable for automation tasks. For instance, nmcli -t -f IP4.ADDRESS dev show eth0 will output only the IPv4 address of eth0 in a clean, parsable format.
HISTORY
nmcli was developed as part of the NetworkManager project to provide a robust and scriptable command-line interface for managing network connections. It emerged as a modern alternative to traditional tools like ifconfig and route for systems managed by NetworkManager, evolving over time to become a comprehensive utility capable of handling complex network configurations and device states. Its focus has always been to offer full control over NetworkManager's capabilities from the terminal, complementing graphical and curses-based frontends.
SEE ALSO
nm-applet(1), nmtui(1), NetworkManager(8), ip(8), systemctl(1)