bash: sudo: apt-get: command not found
Boot into recovery mode.
Immediately after the motherboard / computer manufacturer logo splash screen appears when the computer is booting, with BIOS, quickly press and hold the Shift key, which will bring up a GNU GRUB menu screen. With UEFI press (perhaps several times) the Esc key to get to the GNU GRUB menu screen. Sometimes the manufacturer's splash screen is a part of the Windows bootloader, so when you power up the machine it goes straight to the GNU GRUB menu screen, and then pressing Shift is unnecessary.
The timing when to press the left Shift key can be tricky, so sometimes if you miss it you need to try it again. If that doesn't work try the answers to I can't get the GRUB menu to show up during boot.
You will see a GNU GRUB menu screen that looks like this:
Press the down arrow key until you select the 2nd entry from the top (the one with the recovery mode in the description) and then press Enter twice.
Now you should see this recovery menu:
Press the down arrow key until you select network and press Enter. This is the step I'm worried about. Will the network option give you networking? I don't know, but it's worth a try.
Press the down arrow key one more time and select root and press Enter. Now that you are root you can run commands.
wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.6.6ubuntu0.1_amd64.deb
dpkg -i apt_1.6.6ubuntu0.1_amd64.deb
reboot
After the computer reboots apt will work, so open the terminal and type:
pkexec apt install sudo
sudo apt install coreutils
sudo apt install libedit2 zlib1g libgssapi-krb5-2 libldap-2.4-2 libpam0g libxml2 locales ssl-cert tzdata sysstat
You can also test the first command by simulating it without installing anything:
pkexec apt install --simulate sudo
Related videos on Youtube
Martha Carmen Vergara Trix
Updated on September 18, 2022Comments
-
Martha Carmen Vergara Trix over 1 year
I'm new using Ubuntu and I'm trying to experiment with
pgrouting
Everything went fine until I tried to install posgresql 9.5 on ubuntu 18.04 ... I used the following command:sudo apt-get install libedit2 libpq5 postgresql-client-common zlib1g libgssapi-krb5-2 libldap-2.4-2 libpam0g libxml2 postgresql-common locales ssl-cert tzdata sysstat
But it wasn't installed correctly, so I thought to remove and reinstall and used this:
sudo apt-get remove libedit2 libpq5 postgresql-client-common zlib1g libgssapi-krb5-2 libldap-2.4-2 libpam0g libxml2 postgresql-common locales ssl-cert tzdata sysstat
But something horrible happened: more things were removed than I wanted and I could no longer use my computer, I did not accept commands like
bash sudo apt sudo apt-get
Even the networks were formatted and now I can't be online. Does anyone know how to install everything again without using those commands?
-
user535733 over 5 yearsYes, but you must be skilled with chrooting, which is not easy for a beginner. It's generally easier (and much faster) for a new user to simply reinstall the entire system. Suggestion: Install 16.04 (instead of 18.04), and simply
sudo apt-get install postgresql
. 9.5 is in the 16.04 repositories. Munging an older version onto a newer system is not recommended for new users - bit of a learning curve. -
Xen2050 over 5 yearsUsing synaptic or aptitude should alert you to additional packages that will be installed or removed, and allow a final confirmation before making changes
-
-
Xen2050 over 5 yearsIs the reboot needed to install apt, or is it for getting out of the recovery mode's root shell? Or would immediately installing sudo, coreutils, etc... after apt, while still in the recovery root shell be advised?
-
karel over 5 yearsThe reboot is optional not necessary, but it does have the useful feature that if there are any error messages when running
pkexec apt install sudo
andsudo apt install coreutils
then it will be easier to copy/paste these error messages from the terminal to a .txt file to Ubuntu Pastebin. In case something doesn't work, this will give me another chance to fix it.