I accidentally deleted the network-manager and don't have access to internet anymore
I cannot connect to any wifi connection since I deleted the network-manager. Is there any way to get it from another computer and then install it on mine or is there a way I can get an internet connection without the network-manager?
Solution 1:
I suggest you edit a file:
gksudo gedit /etc/network/interfaces
Amend it to read:
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
wpa-essid myssid
wpa-psk mypasscode
Restart the interface:
sudo ifdown wlan0 && sudo ifup -v wlan0
Test:
ping -c3 www.ubuntu.com
If you get ping results, you are connected. If you wish, you may reinstall Network Manager and revert the file you amended to remove the wlan0 stanza.
Solution 2:
If you haven't rebooted,and still connected, you can run sudo apt-get install --reinstall network-manager
. You're done there.
If you have rebooted the process is a bit more complicated - you will have to get Ubuntu's live cd or usb, and boot it, as if you are about to install Ubuntu anew. Live CD or USB does allow connection to internet, so make sure you're connected . Instead of installing, either press "Try Ubuntu" and access terminal through there, or press Ctrl + Alt + F2 .
Next you need to mount your ubuntu partition (noticce sda1 is just example , find out which one it is with lsblk
) and couple of folders. Thus:
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
By this point you can use live USB / CD to act as if you're working with your actual Ubuntu install, but still using Live USB/CD resources. Now you can run sudo apt-get install --reinstall network-manager
I've used LiveCD/USB recovery quite a few times when I bricked my system. It's one of the best options ever.
There is alternative option - connect through command line, but it will be a somewhat troublesome, especially if you have WPA2 security on your router. You could take your computer (if it's a laptop) to any open/usecure wifi hotspot, but there's too many nopes
Solution 3:
Try this:
Open a terminal,
Press Ctrl+Alt+T
Run it:
sudo iw dev
The iw command will list all the connected WiFi adapters:
phy#0
Interface wlan0
ifindex 3
wdev 0x1
addr f4:ec:38:de:ad:de
type managed
Designated name: phy#1
Device names: wlan0
Interface Index: 3
Address: mac address
Type: Managed. Type specifies the operational mode of the wireless devices.
You can check that if the wireless device is up or not running:
sudo ip link show wlan0
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000
link/ether f4:ec:38:de:ad:de brd ff:ff:ff:ff:ff:ff
In the above example, wlan0 is not UP.
Execute the following command to bring up the WiFI interface:
sudo ip link set wlan0 up
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether f4:ec:38:de:ad:de brd ff:ff:ff:ff:ff:ff
In the above example, now wlan0 is UP.
You check WiFi network connection status running the command:
sudo iw wlan0 link
Not connected.
The output shows that you are not connected to any network.
You scan to find out what WiFi networks are detected, running the command:
sudo iw wlan0 scan
BSS 00:19:e3:fa:b6:9e(on wlan0)
TSF: 25277930826 usec (0d, 07:01:17)
freq: 2437
beacon interval: 100 TUs
capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431)
signal: -46.00 dBm
last seen: 424 ms ago
Information elements from Probe Response frame:
SSID: Adrogue
Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0
DS Parameter set: channel 6
Country: US Environment: Indoor/Outdoor
Channels [1 - 11] @ 30 dBm
ERP: <no flags>
Extended supported rates: 24.0 36.0 48.0 54.0
RSN: * Version: 1
* Group cipher: CCMP
* Pairwise ciphers: CCMP
* Authentication suites: PSK
* Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
HT capabilities:
Capabilities: 0x500c
HT20
SM Power Save disabled
No RX STBC
Max AMSDU length: 3839 bytes
DSSS/CCK HT40
40 MHz Intolerant
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 8 usec (0x06)
HT RX MCS rate indexes supported: 0-15
HT TX MCS rate indexes are undefined
HT operation:
* primary channel: 6
* secondary channel offset: no secondary
* STA channel width: 20 MHz
* RIFS: 0
* HT protection: no
* non-GF present: 1
* OBSS non-GF present: 0
* dual beacon: 0
* dual CTS protection: 0
* STBC beacon: 0
* L-SIG TXOP Prot: 0
* PCO active: 0
* PCO phase: 0
WMM: * Parameter version 1
* BE: CW 15-1023, AIFSN 3
* BK: CW 15-1023, AIFSN 7
* VI: CW 7-15, AIFSN 2, TXOP 3008 usec
* VO: CW 3-7, AIFSN 2, TXOP 1504 usec
---- truncated ----
The two important pieces of information from the above are the SSID
and the security protocol WPA/WPA2 vs WEP
.
The SSID from the above example is Adrogue
. The security protocol is RSN
, also commonly referred to as WPA2
.
Now You will generate a configuration file for wpa_supplicant
that contains the pre-shared key passphrase
for the WiFi network.
sudo wpa_passphrase Adrogue >> /etc/wpa_supplicant.conf 11223344
Where 11223344
was the Network password.
wpa_passphrase
will create the necessary configuration entries based on your input.
Each new network will be added as a new configuration in the configurations file /etc/wpa_supplicant.conf
.
sudo cat /etc/wpa_supplicant.conf
# reading passphrase from stdin
network={
ssid="Adrogue"
#psk="11223344"
psk=42e1cbd0f7fbf3824393920ea41ad6cc8528957a80a404b24b5e4461a31c820c
}
To connect, run the following command:
sudo wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf
-B : Means run wpa_supplicant in the background.
-D : Specifies the wireless driver.
wext : Is the generic driver.
-c : Specifies the path for the configuration file.
Now use dhclient to get an IP address by DHCP:
sudo dhclient wlan0
You can use ip or ifconfig command to verify the IP address assigned by DHCP
sudo ip addr show wlan0
And ping Google’s IP to confirm network connection:
sudo ping 8.8.8.8
Solution 4:
You could always just download the stuff from here or just search for specific packages here depending on which packages you deleted, copy them to a pendrive or something then just do a dpkg -i
on them and voilà, you have whatever installed again.