14

Since my laptop doesnt have a Wireless Network LED indicator, I want to know if there is a command to verify if it is on or off (I'm installing the wireless drivers, so I can't tell if it is set on or off by seeing the list of wireless conections next to the clock)

Raphael Fernandes
  • 143
  • 1
  • 1
  • 5

8 Answers8

20

Edit:

nmcli changed a lot (I am using 16.04) from its previous version. See the original answer below.

To see the connectivity status

$ nmcli general status
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled

To see only wifi status

$ nmcli radio  wifi 
enabled

To see the active connection

$ nmcli connection show --active
NAME         UUID                                  TYPE        DEVICE 
VolCSe  5u6h4521-7k1p-20r3-3g4x-fg19his0j3s8  802-11-wireless  wlp2s0

There are some nice addlitions like, to get the available wifi network informations,

$ nmcli device wifi 
*  SSID                        MODE   CHAN  RATE       SIGNAL  BARS  SECURITY  
*  VolCSe                      Infra  1     54 Mbit/s  73      ▂▄▆_  WPA2      
   Sach                        Infra  4     54 Mbit/s  55      ▂▄__  WPA1 WPA2 
   iKCP                        Infra  5     54 Mbit/s  24      ▂___  WPA2      
   TP-LINK_POCKET_3            Infra  1     54 Mbit/s  12      ▂___  WPA1 WPA2

Note: I have used fictitious ssid and uuid info above.


Old answer:

You can use nmcli for this purpose. Open a terminal type in terminal,

nmcli nm

You will have output like,

RUNNING         STATE           WIFI-HARDWARE   WIFI       WWAN-HARDWARE   WWAN      
running         connected       disabled        disabled   enabled         disabled 

See the third and fourth column which contains information of your interest.

If you want to be more specific only to wifi, then try in terminal,

nmcli nm wifi

it will show the wifi status only,

WIFI      
disabled 
sourav c.
  • 44,715
  • For me, it is showing enabled no matter if I press the keys to activate the wifi. Maybe the keys aren't working, is there a command to enable/disable like it was the key? – Raphael Fernandes Jan 01 '14 at 18:32
  • try nmcli nm wifi on to enable and nmcli nm wifi off to disable – sourav c. Jan 01 '14 at 18:37
  • 1
    yes, this is telling the right result after the installation of the driver. So, the answer is "nmcli nm wifi". Thanks. – Raphael Fernandes Jan 01 '14 at 20:21
  • This did not work for me. It just says WIFI unknown. I could use sudo rfkill block wifi and sudo rfkill unblock wifi instead, as described here. Note that my computer is quite old, so it might be that the network-manager did not recognize my hardware. Also, the OS is Ubuntu 12.04. – Krøllebølle Apr 17 '15 at 16:26
3
rfkill list

This wil show devices that are either software or hardware blocked. In my case it's not blocked and wifi is on:

0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no

When the driver is up and running, the wireless interface should show up in the list when using the following command:

ifconfig
boombanana
  • 84
  • 3
  • For me, it shows Soft blocked: no even if my WiFi is turned off (although hardware is enabled). – nsane Jan 01 '14 at 17:29
3

As of 15.04 (and later, including 16.04 LTS), the nmcli command has changed. There, you'll use:

⟫ nmcli radio
WIFI-HW  WIFI     WWAN-HW  WWAN    
enabled  enabled  enabled  enabled 

or just

⟫ nmcli radio wifi
enabled
3

In my case, i used below commands and the output was 1 if the wifi was enabled else 0. You can try and good luck.

nmcli r wifi | grep enabled | grep -v not | wc -l
  • this still works in 2024 (tested on Debian 12), but what does r mean? I scrolled through all of the man nmcli and I don't see such a command. – Violet Giraffe Feb 12 '24 at 12:44
2

You can use WICD. if it not installed, then just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo apt-get install wicd-gtk

Once installed, run it to see connectivity, Access point connected to, properties, IP settings, and much more.

enter image description here

Mitch
  • 107,631
1

iwlist scanning should do the job.

Jay
  • 2,270
0

In addition to the cli commands listed here there is a cli utility called: nmtui (more info here: https://www.unixarena.com/2015/04/rhel-7-network-management-nmcli-or-nmtui.html )

It has all the convenience of a GUI while being 100% cli (meaning you don't actually need a DE or WM to run it and you can run it out of the tty).

thebunnyrules
  • 1,083
  • 1
  • 13
  • 20
0

One can use ip address or ip addr command instead of slightly old ifconfig. If you know the name of your interface device, you can use ip addr show <device name>. Here's an example ( notice state UP part, which for disabled interface shows up as DOWN):

3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d0:53:49:3d:53:fd brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.2/24 brd 192.168.0.255 scope global dynamic wlan7
       valid_lft 86183sec preferred_lft 86183sec
    inet6 fe80::439:869d:d6ed:c983/64 scope link 
       valid_lft forever preferred_lft forever
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497