Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to connect to WiFi through the Linux command line

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to connect to WiFi through the Linux command line, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Goal: use only command-line tools to configure WiFi

Distributions: those that are suitable for the mainstream

Requirement: Linux with wireless network card installed and root permission.

Difficulty: simple

Agreement:

#-you need to use root permissions to execute specified commands, either directly using the root user or using the sudo command

$- you can use an ordinary user to execute a specified command

Brief introduction

Many people like to use graphical tools to manage computers, but there are also many people who don't like to do so. If you prefer command-line tools, it can be painful to manage WiFi. However, this is not supposed to be the case.

Wpa_supplicant can be used as a command line tool. You can easily set the number WiFi using a simple configuration file.

Scan the network

If you already know the information about the network, you can skip this step. If you don't understand, this is a good way to find out the information on the network.

There is a tool in wpa_supplicant called wpa_cli, which provides a command line interface to manage your WiFi connections. In fact, you can use it to set up anything, but it seems easier to set up a configuration file.

Run wpa_cli with root privileges, and then scan the network.

# wpa_cli > scan

The scanning process takes some time and shows the networks in the area. Remember the network you want to connect to. Then type quit to exit.

Generate a configuration block and encrypt your password

There are more convenient tools for setting up configuration files. It takes the network name and password as parameters and then generates a configuration file that contains the network configuration block in which the password is encrypted.

# wpa_passphrase networkname password > / etc/wpa_supplicant/wpa_supplicant.conf tailor your configuration

Now you have a configuration file, which is / etc/wpa_supplicant/wpa_supplicant.conf. There is not much content, only a network block with a network name and password, but you can modify it on this basis.

Open the file with your favorite editor and first delete the line indicating the password. Then, add the following lines to the top of the configuration.

Ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

This line simply allows users in the wheel group to manage wpa_supplicant. It will be much more convenient.

Other content is added to the network block.

If you want to connect to a hidden network, you can add the following line to tell wpa_supplicant to scan the network first.

Scan_ssid=1

Next, set up the configuration of the protocol and key management. The following are WPA2-related configurations.

Proto=RSNkey_mgmt=WPA-PSK

The group and pairwise configurations tell wpa_supplicant whether you are using CCMP, TKIP, or both. For safety reasons, you should only use CCMP.

Group=CCMPpairwise=CCMP

* *, set the network priority. The higher the value, the higher the connection priority.

Priority=10

Complete WPA_Supplicant Settings

Save the configuration and restart wpa_supplicant for the changes to take effect.

The above is all the contents of the article "how to connect to WiFi through the Linux command line". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report