得之我幸 失之我命

when someone abandons you,it is him that gets loss because he lost someone who truly loves him but you just lost one who doesn’t love you.

nmcli连wifi——从安装完驱动开始

之前提到过wpa_supplicant连接wifi,但那是需要很多前提条件的,比如无线网卡启动等等问题,这次换成networkmanager工具来实现命令行联网,并且将常见排除问题的操作也附上。

  1. 确认本机是否有无线网卡

    1
    $ lspci | grep -i net # 查看网卡设备信息:生产商、型号
  2. 列举所有的网卡设备

    1
    $ ifconfig # 找到无线网卡,假设是wlan0

    1
    $ ip link
  3. 打开wlan接口

    1
    $ ifconfig wlan0 up

    1
    $ ip link set wlan0 up
  4. 这时候可能会遇到一个问题:在图形界面里turn off WiFi,在终端使用ifconfig wlan0 up的时候报错,SIOCSIFFLAGS: Operation not possible due to RF-kill,通过下面的命令解决

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    $ rfkill list # 查看被关闭的射频
    0: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no
    1: tpacpi_bluetooth_sw: Bluetooth
    Soft blocked: no
    Hard blocked: no
    2: phy0: Wireless LAN
    Soft blocked: yes
    Hard blocked: no
    3: phy1: Wireless LAN
    Soft blocked: yes
    Hard blocked: no
    $ rfkill unblock 3 # 解锁wlan,可以看到Wireless Lan的Soft blocked状态变成no了,这样就可以使用ifconfig wlan0 up命令使能无线接口了
  5. 查找所有可用的wifi接入点名称ESSID

    1
    $ iwlist scanning | grep ESSID # 假设是test

    1
    $ nmcli d wifi list
  6. 用nmcli连接指定wifi,不用担心隐藏wifi,也不用担心

    1
    2
    $ nmcli d disconnect # 以防万一先断开
    $ nmcli d wifi connect test password testtest

                            <–either I will find a way, or I will make one.