
In today’s digital age, understanding how to manage your network connections is a valuable skill. This article will guide you through the process of manually connecting and disconnecting to a network using the terminal. We will explore several methods, including using nmcli
, wpa_supplicant
, wicd-curses
, and netplan
.
To connect to a network manually in the terminal, you can use commands like nmcli
to display available access points and connect to a specific one using the SSID and password. You can also use wpa_supplicant
to create a configuration file with network details and connect using that file. Additionally, wicd-curses
provides a console-based network manager for connecting and disconnecting. For Ubuntu 18.04+, you can use netplan
to edit the configuration file and apply the changes to connect to a network.
Using nmcli
(Network Manager Command Line Interface)
nmcli
is a command-line client for NetworkManager. It allows you to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.
Display Available Wireless Access Points
To show the available wireless access points, use the following command:
nmcli dev wifi
Connecting to an Access Point
To connect to an access point, use the following command:
nmcli dev wifi connect $ACCESS_POINT password $PASSWORD
In this command, replace $ACCESS_POINT
with the SSID of the network you want to connect to, and $PASSWORD
with the password of the network.
Disconnecting from a Network
To disconnect from a network, use the following command:
nmcli nm enable false
Using wpa_supplicant
wpa_supplicant
is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with support for WPA and WPA2.
Creating a Configuration File
Create a configuration file (wpa.conf
) with the network details:
network={
ssid="NETWORK_NAME"
psk="NETWORK_PASSWORD"
}
Replace NETWORK_NAME
with the SSID of the network you want to connect to, and NETWORK_PASSWORD
with the password of the network.
Connecting Using the Configuration File
Connect using the configuration file:
wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
In this command, -iwlan0
specifies the wireless network interface, -c/etc/wpa_supplicant.conf
specifies the path to the configuration file, and -Dwext
specifies the driver to use.
Disconnecting from a Network
To disconnect, cancel the connection with CTRL
+C
.
Using wicd-curses
wicd-curses
is a console-based network manager.
Installing wicd-curses
If wicd-curses
is not already installed, you can install it using the following command:
sudo apt-get install wicd-curses
Using wicd-curses
to Connect and Disconnect
Run wicd-curses
and use the right arrow key (→
) to configure and connect to networks. You can disconnect from a network by selecting the network and pressing the Disconnect
button.
Using netplan
(for Ubuntu 18.04+)
netplan
is a utility for easily configuring networking on a linux system.
Editing the Netplan Configuration File
Edit the netplan configuration file (/etc/netplan/50-cloud-init.yaml
) and add the wifi details:
network:
version: 2
wifis:
wlan0:
optional: true
access-points:
"NETWORK_NAME":
password: "NETWORK_PASSWORD"
dhcp4: true
Replace NETWORK_NAME
with the SSID of the network you want to connect to, and NETWORK_PASSWORD
with the password of the network.
Applying the Changes
Apply the changes with the following command:
sudo netplan apply
In conclusion, there are several ways to manually connect and disconnect to a network using the terminal. It’s important to note that you should be cautious when modifying network settings and ensure you have a backup plan, such as a wired connection, in case of any issues.
To display the available wireless access points, use the command nmcli dev wifi
.
To connect to a network, use the command nmcli dev wifi connect $ACCESS_POINT password $PASSWORD
, replacing $ACCESS_POINT
with the SSID of the network and $PASSWORD
with the password.
To disconnect from a network, use the command nmcli nm enable false
.
Create a configuration file (wpa.conf
) with the network details, using the format:
network={
ssid="NETWORK_NAME"
psk="NETWORK_PASSWORD"
}
Replace NETWORK_NAME
with the SSID of the network and NETWORK_PASSWORD
with the password.
Connect using the configuration file with the command wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
. -iwlan0
specifies the wireless network interface, -c/etc/wpa_supplicant.conf
specifies the path to the configuration file, and -Dwext
specifies the driver to use.
To disconnect, simply cancel the connection with CTRL
+C
.
If wicd-curses
is not already installed, you can install it using the command sudo apt-get install wicd-curses
.
Run wicd-curses
and use the right arrow key (→
) to configure and connect to networks. To disconnect from a network, select the network and press the Disconnect
button.
Edit the netplan configuration file /etc/netplan/50-cloud-init.yaml
and add the wifi details using the following format:
network:
version: 2
wifis:
wlan0:
optional: true
access-points:
"NETWORK_NAME":
password: "NETWORK_PASSWORD"
dhcp4: true
Replace NETWORK_NAME
with the SSID of the network and NETWORK_PASSWORD
with the password.
Apply the changes with the command sudo netplan apply
.