On an Ubuntu Linux system, you can use the
iwconfig
command
at a shell prompt, i.e., a command line interface, to view information on
available networks. Iwconfig is part of the wireless-tools package.
If you are currently connected to a wireless network, you will see something similar to the following, if you run the command with no arguments specified. In the example below, the system is connected to a wifi network that has a service set identification (SSID) of T28J5 at a bit rate of 1 Mbs.
$ iwconfig lo no wireless extensions. wlan0 IEEE 802.11bgn ESSID:"T28J5" Mode:Managed Frequency:2.412 GHz Access Point: 00:1F:90:B2:9F:A4 Bit Rate=1 Mb/s Tx-Power=14 dBm Retry long limit:7 RTS thr:off Fragment thr:off Power Management:off Link Quality=70/70 Signal level=-33 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:65 Missed beacon:0 eth0 no wireless extensions.
You can specify a wireless interface to avoid the display of
extraneous information for interfaces that are not wireless interfaces,
e.g., iwconfig wlan0
.
I can see from the above output that the wireless interface supports the 802.11 b, g, and n standards.
The arguments for the command can be seen by issuing the command
iwconfig --help
at a shell prompt.
$ iwconfig --help Usage: iwconfig [interface] interface essid {NNN|any|on|off} interface mode {managed|ad-hoc|master|...} interface freq N.NNN[k|M|G] interface channel N interface bit {N[k|M|G]|auto|fixed} interface rate {N[k|M|G]|auto|fixed} interface enc {NNNN-NNNN|off} interface key {NNNN-NNNN|off} interface power {period N|timeout N|saving N|off} interface nickname NNN interface nwid {NN|on|off} interface ap {N|off|auto} interface txpower {NmW|NdBm|off|auto} interface sens N interface retry {limit N|lifetime N} interface rts {N|auto|fixed|off} interface frag {N|auto|fixed|off} interface modulation {11g|11a|CCK|OFDMg|...} interface commit Check man pages for more details.
You can also use the iwlist
command to display some additional
information from a wireless network interface that is not displayed
by iwconfig. The main argument is used to select a category of
information; iwlist displays in detailed form all information related
to this category, including information already shown by iwconfig.
The options, which you can view by typing
iwlist --help
or just iwlist
at a shell
prompt, for the command are shown below:
$ iwlist Usage: iwlist [interface] scanning [essid NNN] [last] [interface] frequency [interface] channel [interface] bitrate [interface] rate [interface] encryption [interface] keys [interface] power [interface] txpower [interface] retry [interface] ap [interface] accesspoints [interface] peers [interface] event [interface] auth [interface] wpakeys [interface] genie [interface] modulation
If you are connected to a wireless network already, you can view
information on that network by typing ifwlist scan
. E.g.,
in the example below, the system is connected to a wireless network
that has a
SSID of T28J5, which can support a maximum transmission rate of 54 Mbs.
$ iwlist scan lo Interface doesn't support scanning. wlan0 Scan completed : Cell 01 - Address: 00:1F:90:B2:9F:A4 Channel:1 Frequency:2.412 GHz (Channel 1) Quality=70/70 Signal level=-36 dBm Encryption key:on ESSID:"T28J5" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s 11 Mb/s; 12 Mb/s; 18 Mb/s Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s Mode:Master Extra:tsf=0000000733f20181 Extra: Last beacon: 22940ms ago IE: Unknown: 00055432384A35 IE: Unknown: 010882848B0C12961824 IE: Unknown: 030101 IE: Unknown: 0706555320010B1B IE: Unknown: 200100 IE: Unknown: 2A0100 IE: Unknown: 32043048606C IE: Unknown: DD0900037F010100200000 eth0 Interface doesn't support scanning.
If you know the designation for the wireless interface in the system,
e.g. wlan0
in this case, you can avoid attempting to scan
interfaces, such as eth0, which is a wired rather than wireless interface,
by specifying the wireless interface when issuing the command, e.g.,
iwlist wlan0 scan
.
$ iwlist wlan0 scan wlan0 Scan completed : Cell 01 - Address: 00:1F:90:B2:9F:A4 Channel:1 Frequency:2.412 GHz (Channel 1) Quality=70/70 Signal level=-33 dBm Encryption key:on ESSID:"T28J5" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s 11 Mb/s; 12 Mb/s; 18 Mb/s Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s Mode:Master Extra:tsf=000000075edbf181 Extra: Last beacon: 57620ms ago IE: Unknown: 00055432384A35 IE: Unknown: 010882848B0C12961824 IE: Unknown: 030101 IE: Unknown: 0706555320010B1B IE: Unknown: 200100 IE: Unknown: 2A0100 IE: Unknown: 32043048606C IE: Unknown: DD0900037F010100200000
You can see the current bitrate with iwlist <interface>
bitrate
.
$ iwlist wlan0 bitrate wlan0 unknown bit-rate information. Current Bit Rate=1 Mb/s
If you are already connected to a wifi network and want to disconnect
you can type ifconfig interface down
where
interface is the designation for the relevant wireless interface,
e.g., wlan0
. You can see a list of all available interfaces
with ifconfig -a
. If you don't run the ifconfig
wlan down
command from the root account or use sudo on a Ubuntu
system, you will receive a "permission denied" error message. You can use
sudo ifconfig
to run the command from an account with
sudo privileges.
$ ifconfig wlan0 down SIOCSIFFLAGS: Permission denied $ sudo ifconfig wlan0 down [sudo] password for jdoe: $
But with the above method, the system may bring the interface back up
automatically a few seconds later. You can use the command-line tool
nmcli
for controlling NetworkManager, instead. To disable
the wifi interface, you can use nmcli nm wifi off
.
$ nmcli nm wifi off $
You can re-enable the wifi interface with nmcli nm wifi on
.
If the system has previously connected to an available wifi network and
has the credentials stored to automatically connect to that network, when
you issue the nmcli nm wifi on
command, it will automatically
reconnect to the network.
You can see the current status of the wifi interface with nmcli nm
wifi
. E.g., if it is enabled, you would see the following:
$ nmcli nm wifi WIFI enabled
If you wish to see a list of the stored wifi networks you can use
the nmcli con
command, which shows information about
NetworkManager's connections. For information on a particular one
you can use nmcli con list id identifier
, where
identifier is the id for the wireless network, e.g.,
T28J5
or in the example below VA Internet
for
the guest network at a hospital.
$ nmcli con list id "VA Internet" connection.id: VA Internet connection.uuid: 8cd16736-f340-42a8-b103-1b87d24973b9 connection.type: 802-11-wireless connection.autoconnect: yes connection.timestamp: 1434474233 connection.read-only: no connection.permissions: 802-11-wireless.ssid: 'VA Internet' 802-11-wireless.mode: infrastructure 802-11-wireless.band: not set 802-11-wireless.channel: 0 802-11-wireless.bssid: not set 802-11-wireless.rate: 0 802-11-wireless.tx-power: 0 802-11-wireless.mac-address: 90:4C:E5:2F:6F:2E 802-11-wireless.cloned-mac-address: not set 802-11-wireless.mac-address-blacklist: 802-11-wireless.mtu: auto 802-11-wireless.seen-bssids: 802-11-wireless.security: not set ipv4.method: auto ipv4.dns: ipv4.dns-search: ipv4.addresses: ipv4.routes: ipv4.ignore-auto-routes: no ipv4.ignore-auto-dns: no ipv4.dhcp-client-id: not set ipv4.dhcp-send-hostname: yes ipv4.dhcp-hostname: not set ipv4.never-default: no ipv4.may-fail: yes ipv6.method: auto ipv6.dns: ipv6.dns-search: ipv6.addresses: ipv6.routes: ipv6.ignore-auto-routes: no ipv6.ignore-auto-dns: no ipv6.never-default: no ipv6.may-fail: yes