How to reinstall network manager without internet access? – Network manager

Unfortunately, I uninstalled network-manager-gnome using sudo apt-get remove –purge network-manager . I was trying to reinstall it from but without internet connection I cannot do so. What is the solution for this?


Solution 1:

then you will have internet and you can use…


Solution 2:

In terminal type exit . This exits you from the chroot environment.

If you don’t you’ll likely get an unable to connect error.

Edit your /etc/resolve.conf and add at least one nameserver :

You will need to replace <chrootlocation> with the appropriate location of your Ubuntu install, typically the label of the partition it’s installed on. The partition must also be mounted so that you can access it.

Boot a Ubuntu live CD in “Try without installing”. Make sure you are connected to the internet.

If you’ve recently upgraded your network manager you can use sudo apt-get install –reinstall network-manager , but this only works if the package is still in your Apt cache ( /var/cache/apt/archives/ ). I’m guessing you haven’t so you’ll have to do things the long way, but I thought I’d throw that in just in case.


Solution 3:

This answer assumes that you had internet access before losing network-manager or any other packages.

Live CD/DVD/USB

Create a bootable Ubuntu CD/DVD or USB stick, boot from it and select “Try Ubuntu without installing”. Once you get to the Ubuntu desktop, open a terminal.

Root Partition

You need to find out your Root Partition on your Ubuntu installation. On a standard Ubuntu installation, the root partition is “/dev/sda1”, but it may be different for you. To figure out what’s the root partition, run the following command:

sudo fdisk -l

This will display a list of hard disks and partitions from which you’ll have to figure out which one is the root partition. Below in step 3, ROOT-PARTITION is the root partition you just found, for example /dev/sda2 in my case.

Chroot Into Your Root Partition

To make sure a certain partition is the root partition, you can mount it. So let’s mount the root partition along with the /sys, /proc, /run and /dev partitions and enter chroot:

sudo mount ROOT-PARTITION /mnt
for i in /sys /proc /run /dev /dev/pts; do sudo mount --bind "$i" "/mnt$i"; done
sudo cp /etc/resolv.conf /mnt/etc/
sudo chroot /mnt

If you get an error about resolv.conf being identical when copying it, just ignore it. Copying resolv.conf gets the network working, at least for me (using DHCP).

Update/Install Packages

Now you can update the system – in the same terminal, type:

apt-get update
apt-get upgrade
apt-get install network-manager network-manager-gnome

If you have problems on the last step, make sure your sources are correct in /etc/apt/sources.list – in the same terminal, type:

sudo nano /etc/apt/sources.list

Since you’ve chrooted into your Ubuntu installation, the changes you make affect it and not the Live CD, as long as all changes are made in the same terminal session.

Reboot when finished and remove the Live CD. If this answer fixes your problem, please mark it correct. Thanks!