How to use the command "nmcli radio" (with examples)
“nmcli radio” is a command-line tool that allows users to show the status of radio switches or enable/disable them using NetworkManager. It provides information about the status of Wi-Fi and WWAN switches and enables users to toggle them on or off from the command line.
Use case 1: Show status of Wi-Fi
Code:
nmcli radio wifi
Motivation: This use case is useful when you want to check the current status of the Wi-Fi switch on your device. By using the command “nmcli radio wifi,” you can quickly determine whether the Wi-Fi is turned on or off.
Explanation: The “wifi” argument is used to specify that you want to see the status of the Wi-Fi switch.
Example output:
WIFI-HW WIFI WWAN-HW WWAN
enabled enabled enabled enabled
Use case 2: Turn Wi-Fi on or off
Code:
nmcli radio wifi on|off
Motivation: Sometimes you may want to quickly disable or enable the Wi-Fi switch on your device without going through complex user interfaces. The “nmcli radio wifi on” command turns on the Wi-Fi, while “nmcli radio wifi off” command turns it off.
Explanation: The “on” argument is used to enable the Wi-Fi switch, while the “off” argument is used to disable it.
Example output:
Wi-Fi turned on.
Use case 3: Show status of WWAN
Code:
nmcli radio wwan
Motivation: Checking the status of the WWAN (Wireless Wide Area Network) switch is useful when you want to determine if your device’s cellular connectivity is enabled or disabled. With the “nmcli radio wwan” command, you can quickly see the current state of the WWAN switch.
Explanation: The “wwan” argument is used to specify that you want to see the status of the WWAN switch.
Example output:
WIFI-HW WIFI WWAN-HW WWAN
enabled enabled enabled enabled
Use case 4: Turn WWAN on or off
Code:
nmcli radio wwan on|off
Motivation: In certain situations, you may want to enable or disable the WWAN switch on your device. The command “nmcli radio wwan on” turns on the WWAN switch, while “nmcli radio wwan off” turns it off.
Explanation: The “on” argument is used to enable the WWAN switch, whereas the “off” argument is used to disable it.
Example output:
WWAN turned off.
Use case 5: Show status of both switches
Code:
nmcli radio all
Motivation: When you want to obtain the status of both the Wi-Fi and WWAN switches at once, this use case comes in handy. By executing the command “nmcli radio all,” you can see the current status of both switches on your device.
Explanation: The “all” argument is used to request the status of all available radio switches.
Example output:
WIFI-HW WIFI WWAN-HW WWAN
enabled enabled enabled enabled
Use case 6: Turn both switches on or off
Code:
nmcli radio all on|off
Motivation: There may be instances when you need to simultaneously enable or disable both the Wi-Fi and WWAN switches on your device. By utilizing the command “nmcli radio all on,” you can turn on both switches, while “nmcli radio all off” turns them off.
Explanation: The “all” argument is used to specify that you want to toggle all available radio switches. The “on” argument enables both switches, while the “off” argument disables them.
Example output:
Both switches turned off.
Conclusion:
The “nmcli radio” command provides a versatile way to manage the Wi-Fi and WWAN switches on your device through the command line. By using the various arguments, you can query their status or toggle them on or off as needed. This command is particularly useful when dealing with automation scripts or quick configuration adjustments.