The easiest way to fix broken linux installs that are broken and wont boot is by using a Linux Live boot cd, and chroot.
Boot into the (in your case Ubuntu) live boot cd, open a shell.
if your broken install is located on a ext4 or similar partition using lsblk
identify the drive and partition that you broken install is on.
If you have used a Logical Volume then do lvscan
to identify the logical volume
make a dir to mount the broken install on. eg: mkdir /mnt/broken
then mount the broken install eg: mount /dev/sda1 /mnt/broken
or for a logical volume mount /dev/mapper/ubuntu--vg-ubuntu--lv /mnt/broken
In order to use some of the system commands you will need to mount a number of special directories within the broken file structure before chroot, this is what I use, others may use slightly different mounts, but this will work fine.
TARGETDIR="/mnt/broken"
mount -t proc proc $TARGETDIR/proc
mount -t sysfs sysfs $TARGETDIR/sys
mount -t devtmpfs devtmpfs $TARGETDIR/dev
mount -t tmpfs tmpfs $TARGETDIR/dev/shm
mount -t devpts devpts $TARGETDIR/dev/pts
then you need to run chroot /mnt/broken
this will now place you into the broken linux operating system, and you can start repairing the files you deleted incorrectly, apt should work. If you have additional drives that were mounted in your file system mount -a
will mount all drives listed in your fstab file.
you should be able to reinstall the packages/files you delete
- sudo or root shell is assumed for all commands above