First try to login with an installation CD and back up as much data as you can.
At the login screen, press CTRL+ALT+F1 to switch to the tty1 console.
Now type the following commands one by one to fix the broken Ubuntu Linux installation:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/lib/dpkg/lock
sudo rm /var/lib/dpkg/lock-frontend
sudo dpkg --configure -a
sudo apt clean
sudo apt update --fix-missing
sudo apt install -f
sudo dpkg --configure -a
sudo apt upgrade
sudo apt dist-upgrade
Now reboot the system using command:
sudo reboot