Menu Close

Red Hat Training

A Red Hat training course is available for RHEL 8

Chapter 5. Getting started with nmcli

This section describes general information about the nmcli utility.

5.1. The different output formats of nmcli

The nmcli utility supports different options to modify the output of nmcli commands. Using these options, you can display only the required information. This simplifies processing the output in scripts.

By default, the nmcli utility displays its output in a table-like format:

# nmcli device
enp1s0  ethernet  connected  enp1s0
lo      loopback  unmanaged  --

Using the -f option, you can display specific columns in a custom order. For example, to display only the DEVICE and STATE column, enter:

# nmcli -f DEVICE,STATE device
enp1s0  connected
lo      unmanaged

The -t option enables you to display the individual fields of the output in a colon-separated format:

# nmcli -t device

Combining the -f and -t to display only specific fields in colon-separated format can be helpful when you process the output in scripts:

# nmcli -f DEVICE,STATE -t device

5.2. Using tab completion in nmcli

If the bash-completion package is installed on your host, the nmcli utility supports tab completion. This enables you to auto-complete option names and to identify possible options and values.

For example, if you type nmcli con and press Tab, then the shell automatically completes the command to nmcli connection.

For the completion, the options or value you have typed must be unique. If it is not unique, then nmcli displays all possibilities. For example, if you type nmcli connection d and press Tab, then the command shows command delete and down as possible options.

You can also use tab completion to display all properties you can set in a connection profile. For example, if you type nmcli connection modify connection_name and press Tab, the command shows the full list of available properties.

5.3. Frequent nmcli commands

The following is an overview about frequently-used nmcli commands.

  • To display the list connection profiles, enter:

    # nmcli connection show
    NAME    UUID                                  TYPE      DEVICE
    enp1s0  45224a39-606f-4bf7-b3dc-d088236c15ee  ethernet  enp1s0
  • To display the settings of a specific connection profile, enter:

    # nmcli connection show connection_name             enp1s0
    connection.uuid:           45224a39-606f-4bf7-b3dc-d088236c15ee
    connection.stable-id:      --
    connection.type:           802-3-ethernet
  • To modify properties of a connection, enter:

    # nmcli connection modify connection_name property value

    You can modify multiple properties using a single command if you pass multiple property value combinations to the command.

  • To display the list of network devices, their state, and which connection profiles use the device, enter:

    # nmcli device
    enp1s0  ethernet  connected     enp1s0
    enp8s0  ethernet  disconnected  --
    enp7s0  ethernet  unmanaged     --
  • To activate a connection, enter:

    # nmcli connection up connection_name
  • To deactivate a connection, enter:

    # nmcli connection down connection_name