NMCLI Commands Guide for Linux Administrators

NMCLI commands guide for Linux administrators showing NetworkManager network configuration and management
NMCLI Commands Guide
Managing network settings is a fundamental responsibility of every Linux system administrator. Whether you are configuring a new server, assigning a static IP address, changing DNS servers or troubleshooting network connectivity, having a reliable command-line tool can simplify network administration.

NMCLI (NetworkManager Command Line Interface) is a powerful utility that allows administrators to manage NetworkManager directly from the terminal. Instead of manually editing network configuration files, NMCLI enables you to configure interfaces, create connection profiles, modify IP addresses, configure gateways, manage DNS servers and activate network connections with simple commands.

Because it supports automation, scripting and remote server administration, NMCLI has become the preferred networking tool on latest Linux distributions such as RHEL, Rocky Linux, AlmaLinux, CentOS Stream, Fedora and even Ubuntu when NetworkManager is installed.

In this guide, you'll learn how to use NMCLI commands with practical examples, manage NetworkManager connection profiles, configure production networks, troubleshoot common issues and apply Linux best practices.

Before learning NMCLI, it's recommended to understand Linux networking concepts. Read our guide on Linux Networking Basicsfor Beginners.

·       What Is NMCLI?
·       Check Whether NMCLI Is Installed
·       What Is NetworkManager?
·       Why Use NMCLI Instead of Editing Network Configuration Files?
·       Understanding NMCLI Commands and Connection Profiles
·       Check Network Status Using NMCLI
·       Configure Static IP, Gateway, and DNS Using NMCLI
·       Configure DHCP Using NMCLI
·       Manage and Modify Network Connections
·       Verify Network Configuration
·       Common NMCLI Commands and Practical Examples
·       Common NMCLI Errors and Troubleshooting
·       Best Practices for Using NMCLI in Production
·       NMCLI Commands Cheat Sheet

What Is NMCLI?
NMCLI (NetworkManager Command Line Interface) is the official command-line utility for managing Network Manager, a service responsible for configuring and managing network connections in Linux.

Unlike temporary networking commands such as ip addr or ip route, NMCLI modifies connection profiles persistently. These settings remain available even after restarting NetworkManager service or rebooting the server.

If you are new to Linux system administration, start with our beginner-friendly guide explaining What Is Linux? and how Linux systems work.

NMCLI can perform nearly every networking task including:

• Display network devices
• How network connection profiles
• Configure static IP addresses
• Configure gateways
• Configure DNS servers
• Enable or disable DHCP
• Activate or deactivate interfaces
• Rename connection profiles
• Restart network connections
• Verify network configuration

Because it works entirely from the command line so NMCLI is especially useful for remote Linux servers where a graphical desktop environment is unavailable.

Check Whether NMCLI Is Installed
Most modern Linux distributions include NMCLI because it is part of the Network-Manager package. However, before using any NMCLI commands, it's a good idea to verify that the utility is installed on your system.

Run the following command:

nmcli --version

If NMCLI is installed, you'll see the installed version, similar to:
NMCLI version command output showing the installed NetworkManager command-line tool version in Linux

If the command returns "nmcli: command not found", install the NetworkManager package using your distribution's package manager.

Install NMCLI on RHEL, Rocky Linux, AlmaLinux, and CentOS
sudo dnf install NetworkManagerDNF install NetworkManager command used to install NMCLI and NetworkManager on RHEL-based Linux systems

Install NMCLI on Ubuntu and Debian
sudo apt updatesudo apt update command used to refresh package information before installing NetworkManager on Ubuntu or Debian Linux

sudo apt install network-managersudo apt install network-manager command used to install NetworkManager and NMCLI on Ubuntu or Debian Linux systems

After installation verify that the NetworkManager service is running:
systemctl status NetworkManagersystemctl status NetworkManager command showing the NetworkManager service status on a Linux system

If the service is not active, start and enable it using:
sudo systemctl enable --now NetworkManagersudo systemctl enable --now NetworkManager command used to enable and start the NetworkManager service automatically on Linux

Note: Most RHEL, Rocky Linux, AlmaLinux, Fedora, and Ubuntu Desktop installations already include NetworkManager and NMCLI by default, so manual installation is usually unnecessary. This step is mainly helpful for minimal server installations or customized Linux environments.

What Is NetworkManager?
Network Manager is a system service that simplifies network management on Linux systems.  Network Manager stores network settings in profiles of connections and automatically manages network devices instead of editing numerous configuration files manually.

Today, Network Manager is the default networking service on many Linux distributions including:

• Red Hat Enterprise Linux (RHEL)
• Rocky Linux
• AlmaLinux
• CentOS Stream
• Fedora
• Ubuntu Desktop
• Many cloud images

Network Manager stores connection profiles inside:

/etc/NetworkManager/system-connections/

Each connection profile contains network settings such as:

·  Interface name
·  IP address
·  Gateway
·  DNS servers
·  Routing information
·  VLAN configuration
·  Bonding configuration

NMCLI interacts directly with these connection profiles, making network management faster and safer.

Why Use NMCLI Instead of Editing Configuration Files?
Linux administrators can set up networking either manually editing configuration files or with Network Manager via NMCLI. While both methods achieve the same goal, NMCLI offers several advantages.
Feature NMCLI Manual Configuration
Easy to Use ✔ Yes Requires file editing
Persistent Changes ✔ Yes Yes
Automation Friendly ✔ Excellent Limited
Error Checking ✔ Built-in Manual
Production Ready ✔ Recommended Depends on experience
For enterprise environments, NMCLI is generally preferred because it reduces configuration errors and provides a consistent method of managing network settings.

Understanding NMCLI Command Syntax
Before using NMCLI, it's helpful to understand its command structure.

The general syntax is:

nmcli OBJECT COMMAND [OPTIONS]

Examples include:

nmcli device status
nmcli connection show
nmcli connection up ens160
nmcli connection modify ens160 ipv4.addresses 192.168.1.100/24

Most NMCLI commands follow this simple structure: 

Object – Specifies what you want to manage (device, connection, general, networking, etc.)
Command – Defines the action such as show, modify, up, or down
Options – Additional parameters used to configure networking

Learning this pattern makes NMCLI much easier to understand and remember.

Connection Profiles vs Network Devices
One of the most common mistakes that beginners make, is confusing a network device with a Network Manager connection profile. Although they often have similar names but they serve different purposes.

A network device is the physical or virtual network interface detected by Linux such as ens160, ens33 or eth0. It represents the actual network adapter that sends and receives network traffic.

A connection profile, on the other hand, is a Network Manager configuration that stores network settings for a device. It includes information such as the IP address, gateway, DNS servers, routing, and other networking parameters.

For example, the following command displays the available network devices:
nmcli device statusnmcli device status command showing network devices, connection status, and NetworkManager connection profiles on Linux

While this command lists the configured connection profiles:
nmcli con shownmcli device status command showing network devices, connection status, and NetworkManager connection profiles on Linux

On many systems, the device name and connection profile have the same name (for example, ens160), but they can also be different. For instance the device name may be ens160 while the connection profile is named Wired connection 1 or Production Network.

Tip: Mostly NMCLI configuration commands modify the connection profile but not the physical network device. Always verify profile name of the connection with nmcli con show before making network changes.

Check Network Status Using NMCLI
Before modifying any network settings, you should inspect the current network configuration. NMCLI provides several commands to display devices, interfaces, and connection profiles.

Display General Network Status
To verify whether networking is enabled on your Linux server, run:

nmcli general statusnmcli general status command showing the overall NetworkManager status and connectivity state on a Linux system

This command quickly confirms whether the Network Manager service is running and if the server has network connectivity.

Display Network Devices
To list all detected network interfaces:

nmcli device statusnmcli device status command showing network devices, connection status, and NetworkManager connection profiles on Linux

This output shows:

·     Device name
·     Device type
·     Current status
·     Active connection profile

Administrators often use this command before assigning static IP addresses because it identifies the correct interface name.

Display Connection Profiles
To view all available Network Manager connection profiles, use:

nmcli connection shownmcli connection show command displaying all NetworkManager connection profiles and their associated network devices on Linux**

Unlike network devices, connection profiles store the configuration associated with each interface. These profiles contain persistent settings such as IP addresses, gateways, and DNS servers.

Display Detailed Connection Information
To view detailed information for a specific connection profile:

nmcli connection show ens160nmcli connection show command displaying all NetworkManager connection profiles and their associated network devices on Linux

This command displays configuration details including:

·     IPv4 address
·     Gateway
·     DNS servers
·     MTU
·     Interface name
·     Routing settings
·     Auto-connect status

Reviewing these details before making changes helps prevent accidental misconfigurations on production servers.

Configure a Static IP Address Using NMCLI
Most production Linux servers require a static IP address so that services such as web servers, databases, DNS servers, monitoring tools, and firewalls can communicate reliably. Unlike DHCP, a static IP remains unchanged after reboot, making it ideal for enterprise environments.

Before configuring a static IP address, verify the available connection profiles:

nmcli con shownmcli connection show command displaying all NetworkManager connection profiles and their associated network devices on Linux

In this example, ens160 is the active connection profile that will be modified.

Configure a Static IPv4 Address
Assign a static IP address using the following command:

nmcli con mod ens160 ipv4.addresses 192.168.1.100/24nmcli con mod ens160 ipv4.addresses command used to configure a static IPv4 address on the ens160 network connection in Linux

This command assigns:
·     IP Address: 192.168.1.100
·     Prefix Length: 24
·     Subnet Mask: 255.255.255.0

Unlike the ip addr add command, this modification is persistent because it updates the Network Manager connection profile.

For a complete step by step guide covering both temporary and permanent network configuration methods, read our guide on How to Configure Hostname, Static IP,Gateway and DNS on Linux Production Servers.

Configure the Default Gateway
Next configure the default gateway.

nmcli con mod ens160 ipv4.gateway 192.168.1.1nmcli con mod ens160 ipv4.gateway command used to configure the default gateway for the ens160 network connection in Linux
The default gateway allows the server to communicate outside the local network, including internet connectivity and communication with remote subnets.

Verify the gateway after configuration:

ip route
ip route command displaying the routing table and default gateway configuration on a Linux system

Configure DNS Servers
DNS servers translate domain names into IP addresses. Without a properly configured DNS server, internet connectivity may appear to work while domain names fail to resolve.

Configure Google's public DNS servers:

nmcli con mod ens160 ipv4.dns "8.8.8.8 8.8.4.4"nmcli con mod ens160 ipv4.dns command used to configure Google DNS servers 8.8.8.8 and 8.8.4.4 for the ens160 network connection in Linux

Multiple DNS servers improve reliability because the secondary server is used if the primary server becomes unavailable.

Set the IPv4 Method to Manual
After assigning the IP address, gateway, and DNS servers, configure Network Manager to use manual addressing instead of DHCP.

nmcli con mod ens160 ipv4.method manualnmcli con mod ens160 ipv4.method manual command used to set the ens160 network connection to manual static IPv4 configuration in Linux

If you skip this step, Network Manager may continue requesting an IP address from the DHCP server.

Apply the Configuration
Activate the updated connection profile:

nmcli con up ens160nmcli con up ens160 command used to activate the ens160 network connection and apply its Network Manager configuration in Linux

If the connection is currently active, you can restart it instead.

Network Manager reloads the connection profile and applies the new network configuration immediately without requiring a server reboot.

Verify Static IP Configuration
Always verify the configuration after making changes. Display the assigned IP address:

ip addr show ens160ip addr show ens160 command displaying the IP address and network interface details for ens160 in Linux

Check DNS configuration:
cat /etc/resolv.conf

Test internet connectivity:

ping -c 4 8.8.8.8ping -c 4 8.8.8.8 command used to test network connectivity by sending four ICMP packets to Google's DNS server in Linux

Verify DNS resolution:

ping -c 4 google.comping -c 4 google.com command used to test internet connectivity and DNS resolution by sending four ICMP packets to google.com in Linux

If all commands return the expected output, your Linux server is successfully configured with a static IP address using NMCLI.

Configure DHCP Using NMCLI
Although production servers typically use static IP addresses, DHCP is still useful in development environments, virtual machines, and desktop systems.

To switch an interface back to DHCP, configure the IPv4 method:

nmcli con mod ens160 ipv4.method autonmcli con mod ens160 ipv4.method auto command used to configure the ens160 network connection to obtain an IPv4 address automatically using DHCP in Linux

Remove any manually configured IP address:

nmcli con mod ens160 ipv4.addresses ""nmcli con mod ens160 ipv4.addresses command used to remove the manually configured IPv4 address from the ens160 network connection in Linux

Remove the configured gateway:

nmcli con mod ens160 ipv4.gateway ""nmcli con mod ens160 ipv4.gateway command used to remove the manually configured default gateway from the ens160 network connection in Linux

Remove manually configured DNS servers:

nmcli con mod ens160 ipv4.dns ""nmcli con mod ens160 ipv4.dns command used to remove manually configured DNS servers from the ens160 network connection in Linux

Verify that DHCP assigned a new IP address:

ip addr show ens160ip addr show ens160 command displaying the assigned IP address and network interface details for ens160 on a Linux system

Activate and Deactivate Network Connections
Network Manager allows administrators to activate or deactivate connection profiles without restarting the entirenetworking service.

Bring a Connection Up
Activate a connection profile:

nmcli con up ens160nmcli con up ens160 command used to activate the ens160 network connection and apply its Network Manager configuration in Linux

This command applies all settings stored in the Network Manager profile.

Bring a Connection Down
Deactivate a connection:

nmcli con down ens160nmcli con down ens160 command used to deactivate the ens160 network connection in Linux

Administrators often use this command before modifying production network settings.

Modify Existing Network Connections
One of NMCLI's biggest advantages is that it allows administrators to modify existing connection profiles without recreating them.

For example, to change the DNS server:
nmcli con mod ens160 ipv4.dns "9.9.9.9"

Change the gateway:
nmcli con mod ens160 ipv4.gateway 192.168.10.1

Update the static IP address:
nmcli con mod ens160 ipv4.addresses 192.168.10.50/24

After modifying any setting, reactivate the connection:
nmcli con up ens160

This ensures the updated configuration takes effect immediately without rebooting the Linux server.

Rename a Network Connection Profile
Network Manager allows you to rename a connection profile to make it easier to identify, especially on servers with multiple network connections.

To rename a connection profile, run:

nmcli con mod ens160 connection.id Production-Networknmcli con mod ens160 connection.id Production-Network command used to rename a NetworkManager connection profile to Production-Network in Linux

Verify the updated connection name with this command:

nmcli con show

Tip: Use meaningful names such as Production-Network, Backup-Network, or Management-Network to simplify network administration and troubleshooting on production servers.

Configure Auto Connect Using NMCLI
On production servers, network connections should automatically activate after every system reboot. Network Manager uses the autoconnect setting to determine whether a connection profile starts automatically when the system boots.

To enable automatic connection activation, run:

nmcli con mod ens160 connection.autoconnect yesnmcli con mod ens160 connection.autoconnect yes command used to enable automatic activation of the ens160 network connection in Linux

If you want to disable automatic connection activation, use:

nmcli con mod ens160 connection.autoconnect nonmcli con mod ens160 connection.autoconnect no command used to disable automatic activation of the ens160 network connection in Linux

To verify whether Auto Connect is enabled, run:

nmcli con show ens160 | grep autoconnectnmcli con show ens160 piped to grep autoconnect command used to check whether automatic connection activation is enabled for ens160 in Linux

If connection.autoconnect: yes then connection is automatic.

Production Tip: Always enable Auto Connect on production servers unless there is a specific reason to keep the interface disabled after a reboot. This helps to ensure network connectivity is restored automatically when the server starts.

Delete a Network Connection Profile
Over time, Linux servers may accumulate unused or outdated Network Manager connection profiles. Removing obsolete profiles helps keep network configuration organized and avoids confusion during administration.

Before deleting a profile, list all available connections:

nmcli con show

Delete a connection profile:

sudo nmcli con delete ens160sudo nmcli con delete ens160 command used to permanently delete the ens160 Network Manager connection profile in Linux

Note: Deleting a connection profile permanently removes its configuration. Always verify that you are deleting the correct profile, especially on production servers.

Common NMCLI Errors and Troubleshooting
Even experienced Linux administrators occasionally encounter networking issues. The following are some common problems and their solutions.

1. Connection Activation Failed
If the connection fails to activate:

·  Verify the connection profile name
·  Check whether the interface exists
·  Ensure the interface is enabled
·  Review Network Manager logs

Check interface status:

nmcli device status

2. Device Not Managed
Sometimes Network Manager reports:
device not managed

This usually occurs when:

· Network Manager is not managing the interface
·  Another networking service is controlling the device
·  Configuration files conflict

Verify Network Manager status:

systemctl status NetworkManager

3. NetworkManager Service Not Running
If NMCLI commands fail or display errors related to Network Manager, the service may not be running.

Since Network Manager runs as a system service, understanding Linux services and processes can also help during troubleshooting. You can learn more in our LinuxProcess Management for Beginners guide.

Check the service status:

systemctl status NetworkManager

If the service is stopped, start it using:

To ensure Network Manager starts automatically after every system reboot:

sudo systemctl enable NetworkManager

Or start and enable it with a single command:

sudo systemctl enable --now NetworkManager

Verify that the service is running:

systemctl is-active NetworkManager

If the output is:

active then Network Manager is running correctly and ready to manage network connections.

4. Static IP Not Applied
If the configured IP address does not appear:

·  Verify the interface name
·  Confirm the connection profile
·  Ensure ipv4.method is set to manual
·  Reactivate the connection

nmcli con up ens160

5. Wrong Interface Name
Using an incorrect network interface name is a common reason why NMCLI commands fail or do not modify the intended network connection.

To display all available network interfaces, run:

nmcli device status

Or use:

ip link show

Verify that you are using the correct interface or connection profile name before running any NMCLI commands.

6. Wrong Gateway
An incorrect default gateway can prevent the Linux server from communicating with remote networks or accessing the internet.

Display the current routing table:

ip route

If the gateway is incorrect, update it using:

nmcli con mod ens160 ipv4.gateway 192.168.1.1

nmcli con up ens160

Verify the updated gateway:

ip route

7. DNS Resolution Not Working
Verify DNS configuration:

cat /etc/resolv.conf
Test DNS:

dig google.com

If DNS fails but:

ping 8.8.8.8

Works correctly, the issue is almost certainly DNS configuration rather than network connectivity.

8. DNS Configuration Incorrect
Incorrect DNS server settings can prevent domain names from resolving, even if the server has internet connectivity.

Verify the configured DNS servers:

cat /etc/resolv.conf

Test DNS resolution:

dig google.com

Or
nslookup google.com

If DNS resolution fails but the following command succeeds:

ping -c 4 8.8.8.8

The issue is likely related to the DNS server configuration rather than network connectivity.

Best Practices for Using NMCLI in Production
Following best practices help to prevent downtime and configuration errors.

· Backup Existing Connection Profiles
·  Verify Interface Names
·  Test Configuration Before Logging Out
·  Use Meaningful Connection Names
·  Document Network Changes

NMCLI Command Cheat Sheet
Task Command
Show devices nmcli device status
Show connections nmcli con show
Configure static IP nmcli con mod ens160 ipv4.addresses
Configure gateway nmcli con mod ens160 ipv4.gateway
Configure DNS nmcli con mod ens160 ipv4.dns
Enable DHCP nmcli con mod ens160 ipv4.method auto
Bring connection up nmcli con up ens160
Bring connection down nmcli con down ens160
Frequently Asked Questions

Q1. Is NMCLI better than editing configuration files?
For most Linux administrators yes. NMCLI updates Network Manager connection profiles directly by reducing the chance of syntax errors and making network management easier.

Q2. Does NMCLI work on Ubuntu?
Yes. Ubuntu Desktop uses Network Manager by default. Ubuntu Server can also use NMCLI if Network Manager is installed and managing the network interfaces.

Q3. Where is NMCLI configuration files stored? 
Network Manager stores connection profiles in:

/etc/NetworkManager/system-connections/ 

Q4. Can NMCLI configure Wi-Fi connections?
Yes. NMCLI supports Ethernet, Wi-Fi, bridges, bonds, VLANs, VPNs, and many other network connection types managed by Network Manager. 

Q5. Is NMCLI suitable for production servers? 
Yes. NMCLI is widely used in enterprise Linux environments because it provides a reliable, scriptable and consistent way to manage network configurations persistently.

📚 Related Articles

🌐 Linux Networking Basics
Learn the fundamentals of IP addresses, network interfaces, gateways, DNS, and basic Linux networking concepts.
Learn how to configure essential network settings on Linux servers using practical methods.
Start with the basics and understand what Linux is, how it works, and why it is widely used.
Understand Linux processes and services, which can also help when troubleshooting services such as NetworkManager.
Conclusion
NMCLI is one of the most useful command line tools available for networking to Linux administrators. It provides a fast, reliable and script friendly method for managing Network Manager without manually editing configuration files. From configuring static IP addresses to gateways, managing DNS servers to activating network connections, NMCLI simplifies everyday administration tasks while keeping network settings persistent across reboots.

For more Linux tutorials, commands, and practical guides, keep visiting SeekLinux!

Author: Aqeel Anwar

SeekLinux Author
SeekLinux Team
Linux Engineers | DevOps | Security Enthusiasts

SeekLinux Team shares practical Linux tutorials, SSL/TLS certificate guides, commands and DevOps solutions. Our goal is to simplify system administration and help you master real-world server and security tasks.

Learn more about us →

Post a Comment

Previous Post Next Post