connect to wifi from command line

The longer you use the Linux system, the more you are used to command line operations. The most convenient part of the command line is that you can write scripts.

I recently learned to connect to wifi on the command line, which was troublesome at first, but once it is written into a script, it is very convenient.

  1. Generate configuration file
      # wpa_passphrase  SSID  "PASSWORD" > /etc/wpa_supplicant/SSID.conf
    
    At this point, the configuration file contains the information needed to connect to wifi.
  2. connect to wifi hotspot
      # ip link set wlp2s0 up
      # wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/SSID.conf
      # dhcpcd wlp2s0
    
    You can also write these commands into a script.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325017619&siteId=291194637