Connecting to wifi through command prompt in Linux (nmcli)

To connect to wifi with a password

#nmcli d wifi conn MyWifi password ‘xxxxxxx’ iface wlan0

MyWifi is SSID name, replace this with your wifi name (SSID name). Keep your password in place of ‘xxxxxx’

wlan0 interface for wifi network, this you can find with ifconfig command or nmcli command.

To disconnect wifi

# nmcli d disconnect iface wlan0

To see network status

# nmcli d status
DEVICE     TYPE              STATE
eth0       802-3-ethernet    unavailable
wlan0      802-11-wireless   disconnected

To See list of available wifi networks

#nmcli d list

nmcli has 3 OBJECTs
nm              NetworkManager’s status
c[onnection]    NetworkManager’s connections
d[evice]        devices managed by NetworkManager

1. Network Manager (nm)

(COMMAND := { status | permissions | enable | sleep | wifi | wwan }
# nmcli nm status
RUNNING         STATE           WIFI-HARDWARE   WIFI       WWAN-HARDWARE   WWAN
running         disconnected    enabled         enabled    enabled         enabled

# nmcli nm wifi off

# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:95213298 errors:0 dropped:0 overruns:0 frame:0
TX packets:87755319 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:88153431076 (88.1 GB)  TX bytes:73877643984 (73.8 GB)

# nmcli nm wifi on

# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
UP BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:95213298 errors:0 dropped:0 overruns:0 frame:0
TX packets:87755319 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:88153431076 (88.1 GB)  TX bytes:73877643984 (73.8 GB)

2. Network Managers Connection (c)

(COMMAND := { list | status | up | down | delete })

How to list available network manager connections

#nmcli c list

How to delete one of the network manager connection from the list using uuid

# nmcli c delete uuid 58be4adb-a360-46cc-xxxx-8868a8cfxxxx

3. Network device (d)