Table of Contents

Linux Commands Cheat Sheet

nmcli : How to use nmcli command in Linux with examples


nmtui
You can use nmtui when you want to set with TUI from the terminal



Help / Manual

# nmcli -h
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OBJECT
  g[eneral]       NetworkManager's general status and operations
  n[etworking]    overall networking control
  r[adio]         NetworkManager radio switches
  c[onnection]    NetworkManager's connections
  d[evice]        devices managed by NetworkManager
  a[gent]         NetworkManager secret agent or polkit agent
# man nmcli

       connection - start, stop, and manage network connections

       device - show and manage network interfaces


How to use nmcli command

list devices nmcli d ← briefly
nmcli device
nmcli d show ← detail
nmcli device show ← detail
nmcli device show eno1
nmcli device status
check connection nmcli connection
nmcli c
nmcli con
nmcli connection show
Interface Down/Up nmcli connection down eno1
nmcli connection up eno1
nmcli connection down eno1 && nmcli connection up eno1
nmcli c down eno1 && nmcli c up eno1


Restart Interfaces

Restart All Interfaces

# systemctl restart NetworkManager
# nmcli networking off && nmcli networking on

Restart One Interface

# nmcli c reload                <- If you change the configuration file manually

# nmcli c down ens160 && nmcli c up ens160


Check Configuration

##Briefly
# nmcli d
# nmcli device

## Detail
# nmcli d show eno1
# nmcli device show eno1


Configuration of IP

# nmcli connection modify eno1 ipv4.addresses "192.168.0.100/24 192.168.0.1"

# nmcli connection down eno1 && nmcli connection up eno1
# nmcli device show eno1
# nmcli connection modify eno1 ipv4.addresses "192.168.0.100/24"
# nmcli connection modify ens3 ipv4.gateway 192.168.0.1

# nmcli connection down eno1 && nmcli connection up eno1
# nmcli device show eno1


Configuration of DNS

# nmcli connection modify eno1 ipv4.dns "192.168.0.100 192.168.0.101"
# nmcli connection down eno1 && nmcli connection up eno1


Configuration of Routing

How to change about DEFROUTE=no

# nmcli con modify eno1 ipv4.never-default yes
# cat /etc/sysconfig/network-scripts/ifcfg-eno1 |grep DEFROUTE
DEFROUTE=no

How to change about DEFROUTE=yes

# nmcli con modify eno1 ipv4.never-default no
# cat /etc/sysconfig/network-scripts/ifcfg-eno1 |grep DEFROUTE
DEFROUTE=yes
# nmcli connection modify eno1 ipv4.routes "10.0.0.0/24 192.168.0.1"
# nmcli connection down eno1 && nmcli connection up eno1
# nmcli con show eno1   <- check
# nmcli con mod ens0 ipv4.gateway 10.0.0.1
# nmcli connection down ens0 && nmcli connection up ens0
# nmcli con show ens0   <- check





Linux Commands Cheat Sheet