NOTE: This will forcefully quit all graphical programs, you'll lose any unsaved work, and you'll be logged out. Non-graphical programs will not be affected.
TL;DR: on systems with systemd (Ubuntu 15.04 and newer)
sudo systemctl restart display-manager
This will restart the appropriate display manager service (lightdm
till 17.04, gdm3
after, sddm
in Kubuntu, etc.). You can replace display-manager
with lightdm
, gdm3
, sddm
, etc. if needed, but this should be enough.
For other Ubuntu versions, first find which display manager your ubuntu is having with following command:
cat /etc/X11/default-display-manager
Than depending on what display manager, you can use one of the following commands:
Default Ubuntu (with LightDM)
sudo systemctl restart lightdm
Gnome (with GDM)
sudo systemctl restart gdm
KDE (with KDM)
sudo systemctl restart kdm
Note: From 12.10 to 15.04, Kubuntu also uses LightDM.
For MDM (e.g. for Mint Cinnamon)
sudo systemctl restart mdm
I think you want to keep using managed interface (by NetworkManager). nmcli
is a commandâline tool for controlling NetworkManager.
To see list of saved connections, use (<SavedWiFiConn>
)
nmcli c
To see list of available WiFi hotspots (<WiFiSSID>
)
nmcli d wifi list
or:
sudo iwlist <WifiInterface> scanning
To see list of interfaces (<WifiInterface>
)
ifconfig -a
Just change <WifiInterface>
, <WiFiSSID>
, <WiFiPassword>
in the following commands to reflect your setup. If WiFi info already saved, easier way using <SavedWiFiConn>
name of connection as it was saved in NetworkManager.
Ubuntu 16.04
##disconnect
nmcli d disconnect <WifiInterface>
##connect
nmcli d connect <WifiInterface>
Another way:
##disconnect
nmcli c down <SavedWiFiConn>
##connect
nmcli c up <SavedWiFiConn>
Ubuntu 15.10 & previous
##disconnect
nmcli d disconnect iface <WifiInterface>
##connect
nmcli d wifi connect <WiFiSSID> password <WiFiPassword> iface <WifiInterface>
Another way:
##disconnect:
nmcli c down id <SavedWiFiConn>
##connect:
nmcli c up id <SavedWiFiConn>
If your password isn't automatically recognized type this:
nmcli -a c up <SavedWiFiConn>
Reference: man nmcli
Best Answer
you can use iwconfig. I have done it with wep. normally this is enough
iwconfig ethX essid ESSID key open XXXXXXXXXX
and then call the dhcp client with dhclient3 ethx
I'm doing this from memory. But check the manual of iwconfig for more info
man iwconfig