If you have a wireless-enabled computer or laptop, you can connect to the Internet. On Ubuntu, you can use the following command line tools to connect to the Wi-Fi network on the terminal:
Let’s see how to use each of these tools to connect to WiFi from the terminal on Ubuntu 20.4
1) Use nmtui to connect to the WiFi network on the terminal
Nmtui-Network Manager Text User Interface-is a command line tool for network configuration on Linux systems. When executed, it will call a graphical text interface to help users configure the network interface in a simple and effective way.
It can also be used to connect to a wireless network through the following simple steps:
Step 1: Start nmtui
To start nmtui, just open a terminal and run the following command:
The graphical interface will start. Select ‘Activate connectionAs shown in the figure, then use the TAB key to select “it is good‘.
Step 2: Connect to the wireless network
The next screen shows the available network interfaces and wireless networks. As you can see, we have 2 wireless networks in range. Select the WiFi network you want to connect to and click enter. In this case, we chose “Galaxy‘.
Provide the wireless network password in the pop-up dialog box that appears, and then use the TAB key again to select “it is good‘Option.
After successfully connecting to the wireless network, please select the “Back” option to return to the main screen of the nmtui interface, and finally select “drop out‘.
To test your internet connection, you can ping Google’s DNS on the terminal as follows:
2) Use nmcli to connect to the WiFi network on the terminal
The nmcli command line tool is another utility that can be used to connect to wireless or WiFi networks. Please follow the steps below to connect to the wireless network on the terminal.
Step 1: Find out the name of your WiFi adapter and wireless network
Before performing other operations, please use
iwconfig Command to display the wireless interface on the system and check its status
From the above output, we can see that we have a label
wlxc4e9840c3fce. This may be related to your situation. In addition, from the output, we can see that we are not connected to any wireless network.
To list wireless interfaces, just run the following command:
$ iw dev
You can also use the following command to check if the interface is connected to any wireless devices:
$ iw interface_name link
In this case, the command will be:
$ iw wlxc4e9840c3fce link
The output confirms that we are not connected to any wireless network. Now, we continue to the next step and connect to the WiFi network.
Step 2: Connect to WiFi on the terminal
Before connecting to a WiFi network, it is best to scan on the terminal to search for available wireless networks. To do this, run the following command:
$ sudo iwlist wlxc4e9840c3fce scan | grep -i ESSID
The output shows that we have 2 wireless networks that can be connected. We will connect to “GalaxyThe network uses nmcli commands:
$ nmcli dev wifi connect [essid_name] password [insert your password]
After running the command, you should get an output confirming that you have successfully connected to the WiFi network. After that, use the following command to confirm that your interface is connected
iwconfig The command is shown above.
In addition, you can use the following methods to verify:
$ sudo iw wlxc4e9840c3fce link
Generally, most users would rather use graphical methods to select and connect to their preferred wireless network. However, for terminal geeks, connecting to a WiFi network is also a viable option, and only a few simple steps are required.
For earlier versions of Ubuntu (such as Ubuntu 16.04 and Ubuntu 17.10), you can use the wpasupplicant tool to connect to the WiFi network on the terminal. We hope you can now easily connect to your preferred wireless network. Your feedback is very welcome.