LinuxCommandLibrary

nmcli-general

Manage and display network manager general status

TLDR

Show the general status of NetworkManager

$ nmcli [[g|general]]
copy

Show the hostname of the current device
$ nmcli [[g|general]] [[h|hostname]]
copy

Change the hostname of the current device
$ sudo nmcli [[g|general]] [[h|hostname]] [new_hostname]
copy

Show the permissions of NetworkManager
$ nmcli [[g|general]] [[p|permissions]]
copy

Show the current logging level and domains
$ nmcli [[g|general]] [[l|logging]]
copy

Set the logging level and/or domains (see man NetworkManager.conf for all available domains)
$ sudo nmcli [[g|general]] [[l|logging]] [[l|level]] [INFO|OFF|ERR|WARN|DEBUG|TRACE] domain [domain_1,domain_2,...]
copy

SYNOPSIS

nmcli [OPTIONS] OBJECT { COMMAND | help }

PARAMETERS

-t, --terse
    Output in terse (script-friendly) format. This suppresses column headers and other human-readable decorations. Fields are separated by colons (':').

-f, --fields field1,field2,...
    Specify which fields to show in the output. Use a comma-separated list of field names. 'all' displays all available fields, while 'common' shows commonly used fields.

-e, --escape yes|no
    Escape all values in terse mode output. Default is 'yes', which ensures that values containing the field separator are correctly handled.

-m, --mode tabular|multiline
    Set the output mode. 'tabular' (default for most commands) displays data in columns. 'multiline' prints each field on a new line, useful for detailed views.

-c, --colors auto|yes|no
    Control color output. 'auto' (default) uses colors if the output is a terminal, 'yes' forces colors, and 'no' disables them.

-n, --nocheck
    Do not check if NetworkManager is running. Commands might fail if NetworkManager is not active.

-w, --wait seconds
    Wait for NetworkManager to become available. A value of '0' (default) means wait indefinitely.

-a, --ask
    Prompt interactively for any missing parameters, such as passwords or passphrases.

-p, --pretty
    Produce pretty, human-readable output, including column headers and formatted values. (Often default for interactive use).

-s, --show-secrets
    Display sensitive information, such as Wi-Fi passwords, in the output. Use with extreme caution as this exposes credentials.

-v, --version
    Show the nmcli version information.

-h, --help
    Print general help or command-specific help information.

DESCRIPTION

nmcli is a powerful command-line client for NetworkManager, enabling users to manage and monitor network connections and devices directly from the terminal. It provides a consistent and scriptable interface for controlling various aspects of network configuration, from setting up simple Ethernet connections to configuring complex VPNs, Wi-Fi networks, and bond interfaces.

Designed to be both user-friendly for interactive use and robust for scripting, nmcli can display network status, activate or deactivate connections, manage network devices, and control global NetworkManager settings. It has largely superseded older network configuration methods like 'ifup' and 'ifdown' for dynamic network environments, offering a modern and integrated approach to network management on Linux systems.

CAVEATS

When using the --terse output format, careful parsing is required as the exact number and order of fields can vary. Relying on nmcli's terse output for critical scripting tasks may necessitate robust error handling and parsing logic. The --show-secrets option should be used with extreme caution, as it will display sensitive network credentials directly in the terminal, potentially compromising security.

OBJECT TYPES

nmcli commands are structured around specific OBJECT types, each representing a distinct aspect of NetworkManager's functionality. Understanding these objects is fundamental to using nmcli effectively:

connection: Manages network profiles that define how to connect to a network (e.g., Wi-Fi SSIDs, VPN configurations, Ethernet settings).
device: Controls network hardware interfaces (e.g., 'eth0', 'wlan0', 'tun0'), allowing operations like enabling/disabling, viewing status, and restarting.
radio: Manages the global state of wireless technologies like Wi-Fi and WWAN (mobile broadband), enabling or disabling them system-wide.
general: Provides general information about NetworkManager's status and global control settings.
networking: Controls NetworkManager's overall networking state, allowing to enable or disable all managed networking.
agent: Manages NetworkManager secrets agents, which handle user authentication and password storage.
monitor: Allows monitoring NetworkManager events and changes in real-time.

COMMON ARGUMENTS

Many nmcli commands accept common arguments to identify specific connections, devices, or to filter output. These include:

id: Refers to the name of a connection profile.
uuid: Refers to the Universally Unique Identifier of a connection profile, offering a stable and unique way to identify connections.
ifname: Refers to the operating system's interface name for a network device (e.g., 'eth0', 'wlan0').
type: Specifies the type of network connection (e.g., 'ethernet', 'wifi', 'vpn', 'bridge').
state: Used to filter or query based on the current operational state of a device or connection (e.g., 'connected', 'disconnected', 'unavailable').

HISTORY

nmcli is a core component of the NetworkManager project, which was initiated in 2004 to provide a modern, dynamic framework for managing network connections on Linux. It emerged to address the challenges of mobile and wireless networking, offering an alternative to traditional static network configuration files. Over the years, nmcli has matured alongside NetworkManager, becoming the primary command-line tool for interacting with the service across various Linux distributions, reflecting continuous development to meet evolving networking demands.

SEE ALSO

nmcli(1), nmcli-examples(7), NetworkManager(8), nm-online(1), network-manager(8)

Copied to clipboard