The nmcli command on Linux Examples and Usages
This tutorial explains how to use the nmcli command on Linux to view, configure, and manage configurations on network devices and connections.
On Linux, a network device is an Ethernet card. A connection is a collection of settings the Ethernet card needs to connect to the network. A computer can have multiple Ethernet cards with numerous connections but can use only one connection at a given time.
There are many methods for creating, configuring, and managing connections. The nmcli command is one of them. It uses the following syntax.
#nmcli [options] [section] [action]
Let's discuss the above syntax.
Options
Options are optional. They allow us to control the command's default behaviour. For example, you can use them to modify the output to display only the required information in the desired format.
Section

The nmcli command organizes its parameters in the following eight sections.
| Section | Description |
| help | Used to get help related to the nmcli options and parameters |
| general | Used to get the status and global configuration of the NetworkManager |
| networking | Used to start, restart, and manage NetworkManager |
| radio | Used to manage wireless devices and protocols |
| connection | Used to manage connections |
| device | Used to manage network devices |
| agent | Used to configure and manage various security settings |
| monitor | Used to monitor network changes |
Action
You can use the nmcli command to perform various tasks such as displaying information, creating and managing configuration, changing device and connection status, etc. A task is an action. Based on your requirements, you can specify one or more actions.
NetworkManager service
The nmcli command is part of the NetworkManager package. NetworkManager provides the default network service on Linux. You can use the following command to know whether the NetworkManager service is running.
# nmcli -t -f RUNNING general
The systemctl command manages all services. You can use it to start and stop the NetworkManager service. The following command stops the NetworkManager service.
#systemctl stop networkmanager
The following command starts it.
#systemctl start networkmanager
You can use the nmcli command only when the NetworkManager service is running.

The nmcli command examples
To list all available network devices and their current status, use the following command.
# nmcli dev status

As mentioned earlier, a device can have multiple connections. Use the following command to view all of them.
#nmcli con show

To view all configured values of a connection, you need to specify its name as the argument. The following command lists all configured values of the ens160 connection.
#nmcli con show ens160

You can also add a new connection. To add a new connection, use the add option. The following command adds a new connection named custeth1. This connection will receive an IP address from the DHCP server.
#nmcli con add con-name custeth1 type ethernet ifname custeth1 ipv4.method auto

When we add a new connection, the nmcli command creates a new file in the /etc/sysconfig/network-scripts/ directory and stores all configuration values. It uses the connection name as the file name with the ifcfg- suffix.

There are multiple ways to edit a connection configuration file. You can directly edit it using a text editor or a network management tool. You can also use the nmcli command to edit this file.
To update this file using the nmcli command, use the modify option. For example, the following command updates the custeth1 connection. It changes the IP configuration type to manual from DHCP and assigns an IP configuration (IP address 10.0.0.10/8 and default gateway 10.0.0.1)
#nmcli con modify custeth1 ipv4.method manual ipv4.address 10.0.0.10/8 ipv4.gateway 10.10.10.1

You can also view and change the value of a single directive. Use the egrep command to print the value of single or multiple directives. Use the modify option with the nmcli con command to change its value.
The following commands print, change, and reprint the value of the ONBOOT directive.
The ONBOOT directive controls the connection's boot time behaviour. The boot process starts this connection at boot time only if you set its value to yes.

The nmcli command also offers an interactive editor to edit a connection. To edit a connection named custeth1 using the interactive editor, use the following command.
#nmcli con edit custeth1
You can use the help option to list all available options and their usage.

The following image shows how to update the default gateway IP address using the interactive editor.

An interface reads the connection file only when it starts. It does not monitor the changes to the connection file. If you make any change to a connection file, you need to manually update the interface about the change. To force an interface to use the updated connection file, you need to remove the current connection from the interface. After removing the current connection, you need to attach the updated connection again.
To remove an active connection, use the following command.
#nmcli con down [connection name]
To attach a new or updated connection, use the following command.
#nmcli con up [connection name]
The following image shows how to remove an existing connection and add a new connection.

Use the following command to force the NetworkManager service to reread all connection files.
#nmcli con reload

A connection is just a collection of settings. It has no use unless you apply it to an interface. To apply it to an interface, use the following command.
#nmcli con up [connection name]
When activating a connection, you may get the following error.
Error: Connection activation failed: No suitable device was found for this connection. (Device ens160 is not available because the profile is not compatible with the device (mismatching interface name)).
This error indicates that you are activating a connection created for an interface that is unavailable on the system. You can fix this error by changing the interface name in the connection's settings.
When you activate a new connection, the existing connection becomes inactive. The following image shows how to activate and deactivate a connection and fix the interface name error.

The delete option deletes a connection. The following command deletes the connection custeth1.
#nmcli con del custeth1

This tutorial is part of the tutorial series Managing Basic Networking (RHCSA / RHCE) Study Guide. Other parts of this series are the following.
Chapter 01 Managing Basic Networking RHCSA Exam
Chapter 02 Predictable Consistent Network Device Naming
Chapter 03 Linux ip Address Command Usages and Examples
Chapter 04 Linux ip Command Cheat Sheet
Chapter 05 The ip Command v/s the ifconfig Command
Chapter 06 Understanding Linux Network Manager Fundamental
Chapter 07 Managing Linux NetworkManager
Chapter 08 Linux NetworkManager Tools and Utilities
Chapter 09 The nmcli Command on Linux Examples and Usages
Chapter 10 The nmtui Command and Utility on Linux
Chapter 11 The nm-connection-editor Command on Linux
Chapter 12 How to Configure IP Address in Linux
Chapter 13 How to Configure Multiple IP Addresses on Linux
Chapter 14 How to Configure IPv6 on Linux
Chapter 15 Basic Linux Commands for Network Testing
Chapter 16 Network Configuration Files in Linux Explained
Chapter 17 The /etc/hosts, /etc/resolv.conf, and /etc/nsswitch.conf Files
Chapter 18 How to Change the Hostname on Linux
The nmcli command cheat sheet
The following table lists some common usages of the nmcli command.
| Command | Description |
| nmcli dev status | Display the current status of network devices |
| nmcli con show | Display all connections |
| nmcli con show [connection name] | Display all settings of the specified connection |
| nmcli con add | con-name Add a new connection |
| nmcli con mod [connection name] | Modify the specified connection |
| nmcli con up connection name | Activate the specified connection |
| nmcli con down connection name | Deactivate the specified connection |
| nmcli con del connection name | Delete the specified connection |
Author Laxmi Goswami Updated on 2025-11-11