Repair Ubuntu installation

I accidently uninstalled (apt-get purge) lots of important system stuff, including gnome dekstop and whatever-is-responsible-for-internet-connetion, among other things. Is there any way to repair it? Without complete reinstall?

I can access it via command line (terminal) more or less normally. move, copy files, etc., just no apt-get install due to no internet connection. So I guess repairing internet would be first priority… Any way to check why it doesnt work and what needs to be done?

I do have LiveCD I can boot from. So I can manually copy neccessary files from it, if any.

Thanks in advance for your help

Edit: after I boot from my LiveCD I can use internet, however, as soon as I chroot into real filesystem, I cannot use internet from there. Guess it’s how expected to work…

Edit 2: how I fixed it: with the help of people here, I finally did it. I booted from liveCD, copied /etc/resolv.conf to real installation, chrooted there, apt-get install ubuntu-desktop. While installation failed due to many errors, files got downloaded into real installation nevertheless. So I rebooted machine from live cd into real ubuntu, and this time while I still had no internet, apt-get had ubuntu-desktop cached. So I installed ubuntu-desktop and rebooted with GUI this time. After some minor manual fixes (ifupdown managed) I got wireless working too, now it’s only a matter of auto-updates etc., with synaptic. Phew…. thanks again everybody 🙂 Special thanks to ~quack who didnt provide any “formal” answer I could formally accept, but was the most helpfull with comments 🙂

Solution:

if you can run the ifconfig utility (as root), and have a single ethernet adapter which can use DHCP to access the network:

sudo ifconfig eth0 upsudo dhclient eth0 &

That should activate your first ethernet adapter and run dhclient to get it an address via DHCP.  If that works successfully, you might be able to do repair your installation by running:

sudo aptitude install ubuntu-desktop

That command will install the packages which are included in a base Ubuntu install. (you can substitute “kubuntu-desktop” if you use KDE or “xubuntu-desktop” if you use XFCE.

If you cannot get networking at all, the best bet is as Justin suggested above, use apt-cdrom to install the ubuntu-desktop package from your CD.