Skip to content

[Linux] Use the Command Line to Configure WiFi Settings

We are usually accustomed to using the graphical interface to configure WiFi settings; But how do we do the same in a Linux command line terminal?

Some time ago, due to a problem during the installation of my Linux system, it only entered the command line mode after booting (the desktop environment was not successfully installed).

And there was no any network signal, the WiFi interface had no driver.

I had try some methods, finally solve the problem. The solution is recorded as follows:

  • Preparation
  • Install WiFi interface driver
  • Configure WiFi settings

Preparation

We will use the following instructions:

  • ifconfig
  • iwconfig
  • wpa_supplicant

Therefore, it is necessary to confirm whether the instructions exist in the system.

I didn’t have them at the beginning, and there was no network to install. Fortunately, I still have the image file (ISO). After mounting, I can install some tools directly from the image file. ([Solved][Linux] Use APT Command Error in New System: “Media change: please insert the disc labeled …”)


Install WiFi interface driver

I encountered this problem before, I also recorded this solution: [Solved][Linux] No Wi-Fi Adapter Found – Make sure you have a Wi-Fi adapter plugged and turned on

I provide a short version of the record:

sudo apt update
sudo apt install firmware-iwlwifi

sudo modprobe -r iwlwifi
sudo modprobe iwlwifi



Configure WiFi settings

Edit /etc/network/interfaces file. (Assume your WiFi device name is” wlan0″)

# ADD
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-essid "YOUR_SSID"
wpa-psk "YOUR_PASSWORD"


Then you can use the following command:

sudo ifup wlan0


You can successfully start WiFi to connect to the network.


References


Read More

Tags:

Leave a Reply