How to reinstall network manager without internet access?
This answer assumes that you had internet access before losing network-manager or any other packages.
Mục Lục
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!