My question is about Linux in general but lets suppose my ubuntu isn't working property, booting in tty or whatever. I have no internet connection but I have ubuntu live cd. Is it possible to reinstall the desktop environment from live cd?
Yes it is. Either by using the CD as a repository, or by booting into the live session and downloading the package manually and then installing from your normal OS or even by setting up a
chroot environment. IN the examples below, I am using
apt-get xfce as the command you will want to run but
dpkg-reconfigure or whatever else would work as well.
1. Use the CD as a repository.
Say that you've screwed up your desktop and are booting to a command line with no internet access (which shouldn't happen, you can have internet even without a GUI). OK, you can put your CD in your drive and then run
If all goes well, that should detect your CD, mount it and parse it for packages. Once that's done, run
sudo apt-get update to refresh your sources and install your desktop normally. For example:
apt-get install xfce4-desktop.
NOTE: I have not tested this but it is relatively well documented. See, for example, here.
2. Boot into the live session and get the packages you want.
This one requires that you actually have a working internet connection in the live CD environment. First, boot into your normal (broken) OS and install
apt-offline. If your system is already broken, you can download the package here (make sure you also get the dependencies) and install with
sudo dpkg -i apt-offline_1.3.1_all.deb
Once you have it installed run
sudo apt-offline set xfce-offline.sig --install-packages xfce4
Then, take the file that was just generated (
xfce-offline.sig), boot into the live session and run
sudo apt-offline get xfce-offline.sig --no-checksum --bundle xfce-offline.zip
Now, boot back into your local system to install it:
That should result in a list of
.deb files that you can then install manually.
I also found something called keryx which might be worth checking out:
Keryx is a free, open source application for updating Linux. The Keryx Project started as a way for users with dialup, or low-bandwidth internet to be able to download and update packages on their debian based distribution of linux. Mainly built for Ubuntu, Keryx allows users to select packages to install, check for updates, and download these packages onto a USB portable storage device. The packages are saved onto the device and are then taken back to the Linux box that it originated from and are then installed.
Finally, you can also do all this manually with
apt-get from the live session:
sudo apt-get update --print-uris -y | sed "s/'//g" | cut -d ' ' -f 1,2 | while read url target; do wget $url -O ./$target; done
The command above will download all
.deb files needed to install
xfce. See my answer here for more details on how that works.
3. Use the live CD to set up a
Setting up the
chroot is explained in more detail here but the basic procedure is (replace
/dev/sda1 with whichever partition has your
sudo mkdir /mnt/foo sudo mount /dev/sda1 /mnt/foo sudo mount --bind /dev /mnt/foo/dev && sudo mount --bind /dev/pts /mnt/foo/dev/pts && sudo mount --bind /proc /mnt/foo/proc && sudo mount --bind /sys /mnt/foo/sys sudo chroot /mnt/foo
You have now tricked your system into thinking it is booted into your installed OS and you can use
apt-get normally. Once you've finished, exit the
exit and reboot.