{"id":10633,"date":"2021-10-09T16:45:33","date_gmt":"2021-10-09T13:45:33","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10633"},"modified":"2024-03-18T13:45:33","modified_gmt":"2024-03-18T10:45:33","slug":"install-and-use-nmcli-tool-on-debian-linux","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-use-nmcli-tool-on-debian-linux\/","title":{"rendered":"Install and use NMCLI tool on Debian Linux"},"content":{"rendered":"\n
In this tutorial, we provide a step by step guide on how to install and use NMCLI tool on Debian Linux.<\/p>\n\n\n\n
According to man pages:<\/p>\n\n\n\n
NMCLI<\/a> is a command-line tool for controlling NetworkManager and reporting network status. It can be utilized as a replacement for nm-applet<\/strong> or other graphical clients. nmcli<\/strong> is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status<\/em>.<\/p>\n\n\n\n Typical uses include:<\/p>\n\n\n\n On on headless Debian systems, nmcli tool may not be installed by default.<\/p>\n\n\n\n If not installed, then you can run the command below to install it;<\/p>\n\n\n\n The command installs a command line tool, nmcli and nmtui, a text User Interface for controlling NetworkManager.<\/p>\n\n\n\n You can then use nmcli command to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status<\/em>.<\/p>\n\n\n\n The command line syntax for When run with no arguments;<\/p>\n\n\n\n This is the sample output;<\/p>\n\n\n\n To show overall status of NetworkManager;<\/p>\n\n\n\n To show complete information about known devices;<\/p>\n\n\n\n To show information about specific device;<\/p>\n\n\n\n To show an overview on active connection profiles;<\/p>\n\n\n\n Show system hostname using nmcli;<\/p>\n\n\n\n you can even use abbreviations;<\/p>\n\n\n\n To see more example usage of nmcli command, run;<\/p>\n\n\n\n Listing available Wi-Fi APs<\/p>\n\n\n\n Connect to a password-protected wifi network;<\/p>\n\n\n\n Showing general information and properties for a Wi-Fi interface;<\/p>\n\n\n\n Go through more examples on man nmcli-exmaples.<\/p>\n\n\n\n You can also check our example in the links below;<\/p>\n\n\n\n Connect to WiFi in Linux Using NMCLI command<\/a><\/p>\n\n\n\n\n
Using NMCLI tool on Debian Linux<\/h2>\n\n\n\n
apt install network-manager<\/code><\/pre>\n\n\n\n
nmcli<\/code><\/strong> command;<\/p>\n\n\n\n
nmcli [OPTIONS...] {help | general | networking | radio | connection | device | agent | monitor} [COMMAND] [ARGUMENTS...]<\/code><\/pre>\n\n\n\n
nmcli<\/code><\/pre>\n\n\n\n
\nenp0s8: connected to Wired connection 1\n \"Intel 82540EM\"\n ethernet (e1000), 08:00:27:56:8E:61, hw, mtu 1500\n inet4 192.168.58.26\/24\n route4 192.168.58.0\/24\n inet6 fe80::a00:27ff:fe56:8e61\/64\n route6 fe80::\/64\n\nenp0s3: unmanaged\n \"Intel 82540EM\"\n ethernet (e1000), 08:00:27:88:1B:AE, hw, mtu 1500\n\nlo: unmanaged\n \"lo\"\n loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536\n\nUse \"nmcli device show\" to get complete information about known devices and\n\"nmcli connection show\" to get an overview on active connection profiles.\n\nConsult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.\n<\/code><\/pre>\n\n\n\n
nmcli general<\/code><\/pre>\n\n\n\n
STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN \nconnected limited enabled enabled enabled enabled<\/code><\/pre>\n\n\n\n
nmcli device show<\/code><\/pre>\n\n\n\n
\nGENERAL.DEVICE: enp0s8\nGENERAL.TYPE: ethernet\nGENERAL.HWADDR: 08:00:27:56:8E:61\nGENERAL.MTU: 1500\nGENERAL.STATE: 100 (connected)\nGENERAL.CONNECTION: Wired connection 1\nGENERAL.CON-PATH: \/org\/freedesktop\/NetworkManager\/ActiveConnection\/2\nWIRED-PROPERTIES.CARRIER: on\nIP4.ADDRESS[1]: 192.168.58.31\/24\nIP4.ADDRESS[2]: 192.168.58.26\/24\nIP4.GATEWAY: --\nIP4.ROUTE[1]: dst = 192.168.58.0\/24, nh = 0.0.0.0, mt = 100\nIP4.ROUTE[2]: dst = 169.254.0.0\/16, nh = 0.0.0.0, mt = 1000\nIP6.ADDRESS[1]: fe80::f3aa:9e8c:be4b:daf9\/64\nIP6.GATEWAY: --\nIP6.ROUTE[1]: dst = fe80::\/64, nh = ::, mt = 100\nIP6.ROUTE[2]: dst = ff00::\/8, nh = ::, mt = 256, table=255\n...\n<\/code><\/pre>\n\n\n\n
nmcli dev sh enp0s8<\/code><\/pre>\n\n\n\n
nmcli connection show<\/code><\/pre>\n\n\n\n
NAME UUID TYPE DEVICE \nWired connection 1 049a12b7-79f5-3236-bc50-e69be0d2b618 ethernet enp0s8<\/code><\/pre>\n\n\n\n
nmcli general hostname<\/code><\/pre>\n\n\n\n
nmcli g h<\/code><\/pre>\n\n\n\n
man nmcli-examples<\/code><\/pre>\n\n\n\n
More nmcli command usage examples;<\/h3>\n\n\n\n
nmcli device wifi list<\/code><\/pre>\n\n\n\n
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY \n* E0:CC:7A:3F:78:64 SUDO Infra 5 130 Mbit\/s 43 \u2582\u2584__ WPA2 \n E0:CC:7A:3E:40:6C CMT_M-A4 Infra 3 130 Mbit\/s 19 \u2582___ WPA2<\/code><\/pre>\n\n\n\n
nmcli device wifi connect \"$SSID\" password \"$PASSWORD\"<\/code><\/pre>\n\n\n\n
nmcli --ask device wifi connect \"$SSID\"<\/code><\/pre>\n\n\n\n
nmcli -p -f general,wifi-properties device show <\/code><\/pre>\n\n\n\n
\n===============================================================================\n Device details (wlp0s20f3)\n===============================================================================\nGENERAL.DEVICE: wlp0s20f3\nGENERAL.TYPE: wifi\nGENERAL.NM-TYPE: NMDeviceWifi\nGENERAL.DBUS-PATH: \/org\/freedesktop\/NetworkManager\/Devices\/13\nGENERAL.VENDOR: Intel Corporation\nGENERAL.PRODUCT: Wireless-AC 9462\nGENERAL.DRIVER: iwlwifi\nGENERAL.DRIVER-VERSION: 5.4.0-48-generic\nGENERAL.FIRMWARE-VERSION: 48.4fa0041f.0\nGENERAL.HWADDR: 5C:80:B6:86:61:0E\nGENERAL.MTU: 1500\nGENERAL.STATE: 100 (connected)\nGENERAL.REASON: 0 (No reason given)\nGENERAL.IP4-CONNECTIVITY: 4 (full)\nGENERAL.IP6-CONNECTIVITY: 3 (limited)\nGENERAL.UDI: \/sys\/devices\/pci0000:00\/0000:00:14.3\/net\/wlp0s20f3\nGENERAL.IP-IFACE: wlp0s20f3\nGENERAL.IS-SOFTWARE: no\nGENERAL.NM-MANAGED: yes\nGENERAL.AUTOCONNECT: yes\nGENERAL.FIRMWARE-MISSING: no\nGENERAL.NM-PLUGIN-MISSING: no\nGENERAL.PHYS-PORT-ID: --\nGENERAL.CONNECTION: SUDO\nGENERAL.CON-UUID: 2f048f49-9ffd-45f4-91e1-0dab7a88a12b\nGENERAL.CON-PATH: \/org\/freedesktop\/NetworkManager\/ActiveConnection\/7\nGENERAL.METERED: no (guessed)\n-------------------------------------------------------------------------------\nWIFI-PROPERTIES.WEP: yes\nWIFI-PROPERTIES.WPA: yes\nWIFI-PROPERTIES.WPA2: yes\nWIFI-PROPERTIES.TKIP: yes\nWIFI-PROPERTIES.CCMP: yes\nWIFI-PROPERTIES.AP: yes\nWIFI-PROPERTIES.ADHOC: yes\nWIFI-PROPERTIES.2GHZ: yes\nWIFI-PROPERTIES.5GHZ: yes\n<\/code><\/pre>\n\n\n\n