• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

nmcli Command Examples in Linux (Cheat Sheet)

by admin

nmcli is a tool for working with NetworkManager via the command-line. This tool is useful when access to a graphical environment is not available and can also be used within scripts to make network configuration changes.

The following are some example of subcommands you can use with nmcli.

Subcommand Used To
general status View a summary of network connectivity data. View identification information for each NIC. Enable the specified NIC.
connection show Disable the specified NIC.
con up {device ID} Enter interactive mode to configure the specified NIC.
con down {device ID} Watch for events sent by the kernel or by a udev rule.
con edit {device ID} Simulate a udev event running for a device, with results on output.
device status Display the current status of each NIC.

Syntax

The syntax of the nmcli command is:

# nmcli [options] [subcommand] [arguments]

nmcli Command Examples

1. Run an `nmcli` subcommand:

# nmcli agent|connection|device|general|help|monitor|networking|radio command_options

2. Display the current version of NetworkManager:

# nmcli --version

3. Display help:

# nmcli --help

4. Display help for a subcommand:

# nmcli subcommand --help

5. Display the list of all connections using nmcli command as follows:

# nmcli con show

6. Display only the active connections using nmcli command as follows:

# nmcli con show --active

7. Display the details of a connection by specifying the connection ID (NAME) using nmcli command as follows:

# nmcli con show "enp0s3"

8. Display the device (interface) status as connected or disconnected using nmcli command as follows:

# nmcli dev status

9. Display the device details using nmcli command as follows:

# nmcli dev show enp0s3

10. Turn off auto connect for a connection profile as shown in command line here:

# nmcli con mod "static" connection.autoconnect no

11. Specify a DNS server using nmcli con mod command as shown here:

# nmcli con mod "static" ipv4.dns "1.1.1.1"

12. We can further add more values to a key by using the + or – symbol in front of the argument. We can also add another DNS server using nmcli con mod command as shown here:

# nmcli con mod "static" +ipv4.dns "8.8.8.8"

13. We can change the static IP address and gateway for a connection profile as shown here:

# nmcli con mod  "static"  ipv4.address  "50.50.50.50/24" ipv4.gateway

14. We can assign a secondary IP address to the same interface without a gateway in an existing profile as shown here:

# nmcli con mod "static" +ipv4.addresses "70.70.70.100/16"

15. To activate the changes, the connection profile needs to be activated using up with nmcli con command as shown here:

# nmcli con up "static"

16. Delete a connection profile using nmcli del command as shown here:

# nmcli del "static"

17. Disable all managed interfaces using nmcli command as shown here:

# nmcli net off

18. Bring down an interface by temporarily disconnecting the device as shown here:

# nmcli dev dis enp0s8

19. Bring up an interface by connecting the device as shown here:

# nmcli dev con enp0s8

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Configure Persistent Names for Tape Devices in CentOS/RHEL
  2. iptables: command not found
  3. findfs: command not found
  4. aura Command Examples
  5. How to Map Static IP to your Domain (with GoDaddy example)
  6. CentOS / RHEL 6,7 : How to delete an iSCSI Target on the initiator (iSCSI client)
  7. Linux OS Service ‘lm_sensors’
  8. gpg: command not found
  9. jlink: command not found
  10. CentOS / RHEL : How to allow or deny Users to login to VSFTP Server

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright