Ads

How to connect to WiFi from Ubuntu Linux terminal

Connect to WiFi in Ubuntu!

Source: freepik
Source: freepik


In this tutorial, you will learn how to connect to a wireless network from Ubuntu terminal. This is especially helpful if you do not have regular access to Ubuntu Server


Step 1: Identify the name of your wireless network interface

There are several ways to identify the name of your network interface. You can check the IP command, the notified ipconfig command or this file:

ls /sys/class/net

It gives you all the available networking interfaces (Ethernet, WiFi and loopback).

pgamer@techwhiles:~$ ls /sys/class/net

eth0 lo wlan0

Step 2: Edit the NetPlan configuration file with the details of the WiFi interface

The NetPlan configuration file is in the / etc / NetPlan directory. If you check the contents of this directory, you will need to view the files as 01-Network-Manager-All.ML or 50-Cloud-3ML.


If this is an Ubuntu server, you should have a cloud-in file. For desktops, this should be a network-manager file.


Network Manager on the Linux desktop lets you choose a wireless network. You can be difficulties that codes and the wifi access point in that's configuration. This helps you in some cases (such as suspension) where the connection goes down automatically.


Whatever the file is, open it for editing. I hope you are somewhat familiar with Nano Editor, because Ubuntu comes pre-installed with it.

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

YAML files are very sensitive about space, indentation and alignment. Use 4 (or 2, which is already used in YAML files) spaces instead of tabs where you see indentations.


Generally, you need to added the following steps to the access point name (SSID) or it's passwords (commonly):

wifis:

    wlan0:

        dhcp4: true

        optional: true

        access-points:

            "SSID_name":

                password: "WiFi_password"

Again, keep the alignment as I have shown otherwise the YAML file will not be analyzed and it will throw an error.


To view your complete configuration file, it may look like this:

# This file is generated from information provided by the datasource. Changes

# to it won't push across an case reboot. To stop cloud - init

# network configs capabilities, write a file

# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:

# network: {config: disabled}

network:

    ethernets:

        eth0:

            dhcp4: TRUE

            optional: true

    version: 2

    wifis:

        wlan0:

            dhcp4: TRUE

            optional: true

            access-point:

                "SSID_name":

                    password: "Your WiFi_password"

I find it amazing that it works despite the changes that will not be maintained even after rebooting the message.


However, create the configuration using this command:

sudo netplan generate

And now apply it:

sudo netplan apply

Your network should be connected or error if something wrong on your Ubuntu. Try pinging a website or running an app update command.



Post a Comment

0 Comments