How to get Ubuntu wifi information in Terminal. On Ubuntu get wifi connection info using nmcli command. You can scan and list available WiFi networks using nmcli comamnd.
nmcli Command
nmcli, a command line tool for controlling and reporting the network status, can scan and list available WiFi networks regardless of the WiFi being connected to a network or not. This should already be installed on your Linux distribution, it doesn’t require specifying the interface name, and can work without super user (sudo) privileges by default or at least that’s the case in my test on both Fedora and Ubuntu.
nmcli is a command-line tool for controlling NetworkManager and reporting network status. It can be utilized as a replacement for nm-applet or other graphical clients. nmcli is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.
Typical uses include:
1. Scripts: Utilize NetworkManager via nmcli instead of managing network connections manually. nmcli supports a terse output format which is better suited for script processing. Note that NetworkManager can also execute scripts, called “dispatcher scripts”, in response to network events.
2. Servers, headless machines, and terminals: nmcli can be used to control NetworkManager without a GUI, including creating, editing, starting and stopping network connections and viewing network status.
The syntax of the command is:
nmcli [OPTIONS...] {help | general | networking | radio | connection | device | agent | monitor} [COMMAND] [ARGUMENTS...]
Most commonly used command options:
1. wifi [list [ifname ifname] [bssid BSSID]]
List available Wi-Fi access points. The ifname and bssid options can be used to list APs for a particular interface or with a specific BSSID, respectively.
2. -m | –mode {tabular | multiline}
Switch between tabular and multiline output:
1. tabular – Output is a table where each line describes a single entry. Columns define particular properties of the entry.
2. multiline – Each entry comprises multiple lines, each property on its own line. The values are prefixed with the property name.
If omitted, default is tabular for most commands. For the commands producing more structured information, that cannot be displayed on a single line, default is multiline. Currently, they are nmcli connection show ID and nmcli device show.
3. -f | –fields {[field…] | all | common}
This option is used to specify what fields (column names) should be printed. Valid field names differ for specific commands. List available fields by providing an invalid value to the –fields option. all is used to print all valid field values of the command. common is used to print common field values of the command.
If omitted, default is common. The option is mandatory when –terse is used. In this case, generic values all and common cannot be used. This is to maintain compatibility when new fields are added in the future.
4. -t | –terse
Output is terse. This mode is designed and suitable for computer (script) processing.
5. -p | –pretty
Output is pretty. This causes nmcli to produce easily readable outputs for humans, i.e. values are aligned, headers are printed, etc.
Using nmcli Command
The nmcli command can be used to show the available wireless networks SSID, mode, channel, transfer rate, signal strength, bars and security used using the following set of commands:
The most basic usage of nmcli command is
nmcli dev wifi
This is how the command output looks:
If you are unable to see any output, try running the command it with sudo:
sudo nmcli dev wifi
If you want more additional information about the scanned WiFi networks, including the SSID-HEX, BSSID, frequency, and more, run the nmcli command like this:
nmcli -f ALL dev wifi
In case you want to switch to multiline view, so you don’t have to expand the terminal window width to see all the details, use -m multiline, like this:
nmcli -m multiline -f ALL dev wifi
You can also use the nmcli command for usage in scripts, using the terse (-t): nmcli -t -f ALL dev wifi