How to connect to WiFi from command line interface on ubuntu server.


 

Follow the steps to connect to wifi:

Step-1: Let's see your wifi device name:

ls /sys/class/net
Immediately you will be able to see your wifi device name. Note it down for later use.


Step-2: Now type:

sudo nano /etc/netplan/50-cloud-init.yaml                                            

Step-3: You will see blank YAML file or something like if you already added any wifi earlier

    wifis:
        wlan0:
            optional: true
            access-points:
                "SSID-NAME-HERE":
                    password: "PASSWORD-HERE"
            dhcp4: true

Step-4: Now type again

sudo netplan apply

Step-5: If everything you did as mentioned, than you can able to see the IP address.

ip a

Step-6: If not working, then you can debug and check the errors to find the issue. 


 sudo netplan --debug apply
 I searched over the internet and then I found this solutions and shared here for later use and also for people who ever facing similar issues.

Comments