nmcli-device
Manage network devices through command line
TLDR
Print the statuses of all network interfaces
Print the available Wi-Fi access points
Connect to a Wi-Fi network with the specified SSID (you will be prompted for a password)
Print the password and QR code for the current Wi-Fi network
Print detailed information about a device
SYNOPSIS
nmcli [OPTIONS] device { COMMAND } [ARGUMENTS]
PARAMETERS
status
Lists the state of all NetworkManager-controlled network devices. This provides a quick overview of network interfaces, their types, and current status (e.g., 'connected', 'disconnected', 'unavailable').
show [IFNAME]
Displays detailed information about a specific network device identified by its interface name (e.g., 'eth0', 'wlan0'). If IFNAME is omitted, it shows details for all devices. Information includes general device properties, IP configuration, hardware address, and the active connection profile.
disconnect IFNAME
Deactivates and disconnects a specified network device. This prevents NetworkManager from using the device until it is explicitly reconnected or a connection is activated on it. It does not delete the device or its connection profiles.
connect IFNAME
Activates a specified network device. If a suitable connection profile exists and is configured for automatic connection, NetworkManager will attempt to bring the device up and connect using that profile. This can be used to re-enable a previously disconnected device.
delete IFNAME
Deletes a software-based network device, such as a bridge, bond, or VLAN interface, that was previously created by NetworkManager. This command does not apply to physical hardware devices.
set IFNAME managed {yes|no}
Controls whether NetworkManager should manage a specific device. Setting it to 'no' will cause NetworkManager to ignore the device, leaving it unmanaged. Setting it to 'yes' brings it back under NetworkManager's control. This is useful for troubleshooting or integrating with other network management tools.
General nmcli options
The nmcli device command also supports general nmcli options like --terse (-t) for machine-parsable output, --fields (-f) to specify output columns, and --pretty (-p) for enhanced readability.
DESCRIPTION
The nmcli device command is a powerful subcommand of the nmcli utility, designed for interacting with and managing network interfaces (devices) controlled by NetworkManager. It provides a command-line interface to view device status, show detailed information, disconnect or connect devices, and even delete software-based interfaces like bridges or bonds.
NetworkManager is a system network service that manages network connections. The nmcli device command allows administrators and users to get a quick overview of all active and inactive network interfaces, diagnose connectivity issues, and manually control device states. It's an essential tool for scripting network configurations and monitoring in Linux environments where NetworkManager is in use.
CAVEATS
The nmcli device command requires the NetworkManager service to be running. Modifying device states (e.g., `disconnect`, `connect`, `delete`, `set`) often requires root privileges or membership in a privileged group. This command primarily manages devices recognized and controlled by NetworkManager; some low-level kernel-managed interfaces might not be directly configurable via nmcli device.
DEVICE STATES
Understanding the 'STATE' column in nmcli device status output is crucial. Common states include 'connected' (device is active and connected), 'disconnected' (device is active but not linked to a network), 'unavailable' (device is present but not usable), and 'unmanaged' (NetworkManager is ignoring the device).
INTERACTION WITH CONNECTIONS
While nmcli device manages the hardware interface, nmcli connection manages the network profiles. A device needs an active connection profile to become 'connected'. Disconnecting a device (nmcli device disconnect) deactivates the current connection on that device, but the connection profile remains available for future use.
HISTORY
The nmcli command-line tool, including its device subcommand, was introduced as part of the NetworkManager project, which gained prominence in the mid-2000s as a daemon to simplify network configuration on Linux. nmcli emerged as the preferred command-line interface for NetworkManager, offering a more powerful and scriptable alternative to older tools and configuration files. The `device` subcommand has been a core component since `nmcli`'s early development, providing essential capabilities for managing network interfaces.
SEE ALSO
nmcli(1), nm-settings(5), NetworkManager(8), ip(8), nmtui(1)