49

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?

2
  • do you have access to other machines with same OS of this machine?
    – Maythux
    Feb 19, 2014 at 5:37
  • It is dangerous piece of software at very bad state ans should be avoided at all costs. So do not use it. NEVER
    – kakaz
    Mar 16, 2020 at 10:46

13 Answers 13

65
sudo dhclient eth0

then you will have internet and you can use...

sudo apt-get install network-manager
9
  • 3
    Note: this is trickier if you have WiFi, but if you can remove your WiFi password (using a second laptop), then the instructions at askubuntu.com/a/294320/67747 get simple enough that this worked for me: sudo iwconfig <device> essid <access_point_name> && sudo dhclient <device> I did not need ifconfig <device> up or similar in my case.
    – sage
    Sep 12, 2017 at 15:37
  • 1
    Would work, if you can get access to internet with cabel. But than should make reboot Dec 11, 2017 at 13:01
  • 7
    I love you so much
    – Mark
    Dec 23, 2017 at 5:48
  • 2
    "Cannot find device eth0" :( Jul 31, 2019 at 15:37
  • 2
    if you run sudo iwconfig you will see the devices. in my case I did not have eth0 for the name of my wired connection. Nov 3, 2019 at 14:17
23

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.

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

  2. In terminal type:

    sudo mount --bind /dev /<chrootlocation>/dev
    sudo mount --bind /proc /<chrootlocation>/proc
    sudo mount --bind /sys /<chrootlocation>/sys
    sudo cp /etc/resolv.conf /<chrootlocation>/etc/resolv.conf
    sudo chroot /<chrootlocation>
    

    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.

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

    nameserver 8.8.8.8 # Google Public DNS
    
  4. In terminal type:

    sudo apt-get update
    sudo apt-get install network-manager
    

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

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

  6. In terminal type sudo reboot to reboot your computer.

8
  • 1
    there needs an internet connection for sudo apt-get update command. Feb 19, 2014 at 5:07
  • 1
    there would be in the chroot. the reason he has no internet is because he uninstalled the network manager, the livecd will have network manager installed so he can use that to connect and install to the other ubuntu installation.
    – mango
    Feb 19, 2014 at 5:08
  • The way I read the question is that the user is on a computer that is normally connected to the internet, but because he uninstalled the network-manager he's currently unable to connect to the internet. Using a livecd get's around this issue. Quote: "I was trying to reinstall it from but without internet connection i cannot do so". Perhaps I've read it wrong?
    – mango
    Feb 19, 2014 at 5:17
  • Also bind the run directory, otherwise you will probably be getting unable to resolve hostname errors: sudo mount --bind /run /chrootlocation/run
    – Dziamid
    Mar 17, 2015 at 11:08
  • This didn't work for me - although the live CD has access to the network, as soon as I chroot the network access (for the chrooted command line) vanishes. Aug 5, 2015 at 3:18
12

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!

3
  • I had a crash on my network-manager on Ubuntu 14.04 and this work for me! Thank you very much!!!
    – CRachid
    May 14, 2016 at 16:47
  • This worked, although I had to do a apt-get -f install (nothing else) to get dependencies(?) to go in. Then the apt-get install network-manager network-manager-gnome. I had hosed my networking by removing wpasupplicant which wanted to remove everything network, but a reinstall of wpasupplicant didn't reinstall the network stuff.
    – 147pm
    Mar 28, 2017 at 12:55
  • Great! Thanks. Confirmed working on Ubuntu 16.04 Unity
    – aleksk
    Nov 7, 2017 at 2:19
7
sudo apt-get remove --purge network-manager

The above command will purge all the packages that was related to the service network-manager.You can download all packages as .deb file using a Ubuntu Live disk and then install it to your original OS.

  • First boot from a Ubuntu Live disk.

  • Once you go there open a terminal and run the below command,

    sudo apt-get download network-manager*
    
  • This will download all the network-manager packages to the home directory.

  • Now copy all the .deb packages to a folder in that pen drive or other partitions in your HDD and then reboot to your system.

  • Once you go there open terminal and do the following:

    cd /path/to/the/directory/where/.deb/files/are/located
    sudo dpkg -i *.deb
    
  • The above command will install all the .deb files.

  • Now restart your network-manager by running sudo service network-manager restart

Now you have the package network-manager-gnome running again.

3
  • 1
    The OP has asked for a solution where he can do this without access to internet.
    – jobin
    Feb 19, 2014 at 9:28
  • 3
    The OP has no Internet due to the removing of the network-manager-gnome package, but this doesn't mean that he has no Internet. Also be aware that using Live CD will not rely on the host package so he'll get access to Internet
    – Maythux
    Feb 19, 2014 at 10:29
  • 1
    Remove network-manager, now how connect to download packages? :-/ thanks for the additional problem.
    – momo2047
    Jan 30, 2015 at 17:43
6

Just solved this same problem, follow these simple steps:

  1. Download network-manager in a device having internet connection from http://security.ubuntu.com/ubuntu/pool/main/n/network-manager/
    I used network-manager_1.2.2-0ubuntu0.16.04.4_amd64.deb for ubuntu16.04

  2. Then transfer this file using USB or phone etc.

  3. $ sudo dpkg -i network-manager_1.2.2-0ubuntu0.16.04.4_amd64.deb

It may happen that the wifi shortcut might be missing on the top, for that just use this command

sudo apt-get install ubuntu-desktop and then a normal restart of your machine.

Done :)

3
  • 1
    Thanks, it worked like a charm in Ubuntu 16.04. Easiest solution.:)
    – john400
    Jun 26, 2018 at 4:42
  • 1
    If you do not have access to a USB drive (e.x. you are on vacation and you forgot it), then you can use the SD-card found in just about every camera to transfer over the file so long as both computers have SD-card slots.
    – Jack G
    Jul 28, 2019 at 21:06
  • 1
    DO NOT RUN THE APT AUTOFIX!!! It uninstalled the Cinnamon package from my Linux Mint computer and led me down a path towards reinstalling my Linux Mint from scratch.
    – Jack G
    Jul 29, 2019 at 11:38
5

Follow official Ubuntu communuty LiveCdRecovery Update Failure section: (https://help.ubuntu.com/community/LiveCdRecovery):

  1. Boot the Ubuntu Live CD.
  2. Press Ctrl-Alt-F1
  3. Run:

    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
    
  4. Add OpenDNS name servers to your /etc/resolv.conf to access the network after chroot:

    nameserver 208.67.222.222
    nameserver 208.67.220.220
    
  5. Run:

    apt-get install network-manager
    

This helped to fix the same issue on my Ubunty 14.04LTS

1
  • This worked perfectly for me on 20.04 though /dev/sda1 was the live USB and I had to change that to the correct partition where the ubuntu root partition was installed. I had / and /home on different partitions.
    – Jonathan
    Dec 17, 2021 at 8:38
4

I know I'm a little late on this but I just ran into this same problem. I installed arping (sudo apt-get install arping) which removed iputils-arping, network-manager, and network-manager-gnome. I edited the /etc/network/interface file to setup a manual IP for eth0.

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# below are my changes

auto eth0
iface eth0 inet static
    address x.x.x.x
    gateway y.y.y.y
    netmask z.z.z.z
    network a.a.a.a
    broadcast b.b.b.b
    dns-nameserver c.c.c.c d.d.d.d

Change x, y, z, a, c, and d to your network settings. I then ran "sudo service network-interface restart INTERFACE=eth0" to restart the interface. This allowed my to reinstall network manager (sudo apt-get install network-manager). I had to purge the arping package I installed before network manager would reinstall. Then start network manager (sudo service network-manager start). Once I had network manager running I changed /etc/network/interface back to default (and kept a copy of the manual change just in case). Hopefully this helps.

2

My previous answer assumes that the reason you cannot access the internet is because you uninstalled "network-manager", and that normally the computer is connnected to the internet. However on the off chance that I read your question wrong, and this is in fact a computer that isn't ever connected to the internet you will need to use this answer instead though it will be more time consuming.

Step #1 = On another computer (It can be running Windows, doesn't matter), go to "http://packages.ubuntu.com/precise/network-manager". (This link assumes you are using Ubuntu 12.04, if not you will need to find the link appropriate to your version).

Step #2 = At the bottom of the web page there is a link for "amd64" and "i386", click on the approriate one. I'm using amd64 so my steps will assume that.

Step #3 = On the new page there are a bunch of mirror links that are direct download links for "network-manager_0.9.4.0-0ubuntu3_amd64.deb". Pick a link, and download the .deb file.

Step #4 = On the first url I provided it also lists the dependencies for network-manager. You may have some of these still installed, but for the ones you don't you will need to download them as well by visiting their page and selecting a mirror.

Step #5 = Once you've downloaded all the .debs you will be needing transfer them to the Ubuntu computer and put them in "/var/cache/apt/archives". You will need root privileges to do this which can be achieved with "gksu nautilus /var/cache/apt/archives". You could also use dpkg to install them, but it won't tell if you've forgetten a dependency so I'm not going to get into how to use that.

Step #6 = In terminal type "sudo apt-get install --reinstall network-manager".

1
  • If this is a computer that isn't ever connected to the internet, then what would you need network-manager for anyway? The answer is connecting to a local intranet to access resources such as printers or scanners, or other local services. Oct 21, 2015 at 16:28
1

A newbies successful answer 16.04LTS Was having trouble with network manager slowing/disconnecting with new internet provider Rashly, decided to switch back to wicd and removed network manager via command line Found couldn't get wicd working (stupidly wasn't finding any networks anyway)

Solution First downloaded appropriate network manager deb file on another computer (32bit/i386 for me)(mine was network-manager_1.2.2-OubuntuO,16.04.4_i386.deb) moved file across to ubuntu system laptop using memory card

took time to find out the following - simply double clicked on transferred deb file (on my desktop) and it installed itself (had major problems using the command line)

internet now connected - but not perfect - no icon

so I updated using command: sudo apt-get update Then install NetworkManager: sudo apt-get install network-manager-gnome network-manager

Once rebooted, t his appears to have given me back my icon and full network manager operation

Hope this is helpful for you as it was for me step 1 - get the correct networ-manager deb file from packages website (mine was network-manager_1.2.2-OubuntuO,16.04.4_i386.deb) move it to you ubuntu computer - double click it and install step 2 update and (re)install network manager via command line/terminal, and get missing parts, problems and updates sorted. good luck

1

I also needed to install network-manager without the internet. I got the idea from another post to add the cdrom: [Ubuntu install DVD/CD] to the software sources in Software and Updates on the 'Other Software' tab. The cdrom source was already listed but not checked so I checked it. Then I used Synaptic Package Manager to install 'network-manager'. I guess I could have used Ubuntu Software instead. This worked for me in Ubuntu 18.10

1

I had the same problem on a Ubuntu 20.04 installation. This was on a desktop machine, without WiFi. The dhclient thing did not work for me. So I managed to set a fixed IP. You need to know your router IP, and a free IP on your network (example done as root, # is the prompt)

  1. First figure out what your device name is:

    # lshw -C network | grep "logical name"
    

    If you have multiple network ports, if you don't know which one to use experiment with each one.

  2. Create a static IP

    # ip addr add 192.168.1.123/24 dev yourdevname
    

    where yourdevname is taken from the lshw logical name

  3. Add a default gateway route

    # route add default gw 192.168.1.1
    

    Note that you need to know the IP of your router

  4. Edit /etc/resolv.conf and add/change/set it to the following two lines (backup old file if you like)

    nameserver 8.8.8.8
    nameserver 9.9.9.9
    

    You can use different IP addresses if you know your DNS server IP. The above two listed should get you going.

That's it, hopefully you have full internet access again.

0

For me, it turned out that I accidentally deleted /etc/resolv.conf and then got the same symptoms (nslookup nba.com doesn't work, but nslookup nba.com 4.2.2.4 does work, when 4.2.2.4 was configured as my DNS server).

Restoring the file from a live USB solved the issue.

-1

Manually configure your ethernet card in /etc/network/interfaces and restart the networking service. Then apt-get update.

2
  • Manually configure your ethernet card in /etc/network/interfaces and restart the networking service. Then apt-get update.
    – Jan
    Oct 27, 2015 at 12:51
  • 3
    This doesn't really answer the question. Oct 27, 2015 at 22:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .