Using the `iw` command (with examples)

Using the `iw` command (with examples)

The iw command is a powerful tool for managing and manipulating wireless devices on Linux. It allows you to scan for available wireless networks, connect or disconnect from a network, and retrieve information about the current connection. In this article, we will explore different use cases of the iw command with code examples.

Use Case 1: Scanning for available wireless networks

To scan for available wireless networks, use the following command:

iw dev wlp scan

Motivation:

  • Scanning for available wireless networks can be useful when you want to see a list of networks in your vicinity. Whether you’re troubleshooting network issues, looking for a specific network to connect to, or simply curious about the wireless networks around you, this command can provide valuable information.

Explanation of arguments:

  • iw is the command itself.
  • dev is short for “device” and specifies the wireless device you want to scan with.
  • wlp is the device name for the wireless LAN (WLAN) interface.
  • scan is the action to perform, which tells iw to scan for available networks.

Example output:

BSS 00:11:22:33:44:55(on wlp1s0)
        TSF: 0 usec (0d, 00:00:00)
        frequency: 2412
        beacon interval: 100 TUs
        capability: ESS Privacy ShortSlotTime (0x0411)
        signal: -45.00 dBm
        last seen: 0 ms ago
        SSID: Example_Network

Use Case 2: Joining an open wireless network

To join an open wireless network, use the following command:

iw dev wlp connect SSID

Motivation:

  • When you are in range of an open wireless network, such as a public hotspot or an open network at a coffee shop, you might want to connect to it to access the internet. This command allows you to easily connect to an open network using its SSID (Service Set Identifier).

Explanation of arguments:

  • iw is the command itself.
  • dev is the wireless device to connect with.
  • wlp is the device name for the WLAN interface.
  • connect is the action to perform, which tells iw to connect to a network.
  • SSID is the name of the open network you want to join.

Example output:

Connected to 00:11:22:33:44:55 (on wlp1s0)
        SSID: Example_Network
        freq: 2412
        signal: -45 dBm

Use Case 3: Closing the current connection

To close the current wireless connection, use the following command:

iw dev wlp disconnect

Motivation:

  • Sometimes you may want to disconnect from a wireless network for various reasons, such as conserving battery, switching to a different network, or troubleshooting network issues. This command allows you to gracefully disconnect from the current network.

Explanation of arguments:

  • iw is the command itself.
  • dev is the wireless device to disconnect with.
  • wlp is the device name for the WLAN interface.
  • disconnect is the action to perform, which tells iw to disconnect from the network.

Example output:

Disconnected from 00:11:22:33:44:55 (on wlp1s0)

Use Case 4: Showing information about the current connection

To retrieve information about the current wireless connection, use the following command:

iw dev wlp link

Motivation:

  • It can be useful to gather information about the current wireless connection, such as the signal strength, frequency, or the SSID of the connected network. This command provides detailed information about the current connection, which can be helpful in troubleshooting or monitoring the network.

Explanation of arguments:

  • iw is the command itself.
  • dev is the wireless device to retrieve information from.
  • wlp is the device name for the WLAN interface.
  • link is the action to perform, which tells iw to show information about the current connection.

Example output:

Connected to 00:11:22:33:44:55 (on wlp1s0)
        SSID: Example_Network
        freq: 2412
        signal: -45 dBm

In conclusion, the iw command provides a versatile set of functionalities for managing wireless devices on Linux. Whether you need to scan for available networks, connect or disconnect from a network, or retrieve information about the current connection, this command is an invaluable tool for wireless network management.

Tags :

Related Posts

How to use the command "doctl kubernetes options" (with examples)

How to use the command "doctl kubernetes options" (with examples)

The doctl kubernetes options command provides a way to retrieve information about available options for working with Kubernetes clusters in DigitalOcean.

Read More
How to use the command 'go bug' (with examples)

How to use the command 'go bug' (with examples)

The ‘go bug’ command is used to report a bug in the Go programming language.

Read More
How to use the command "is-up" (with examples)

How to use the command "is-up" (with examples)

The command “is-up” is a CLI tool that allows you to check whether a website is up or down.

Read More