One of things you have to do when running Ubuntu on a linux server is some type of regular maintenance.

Usually this means installing updates every so often.

sudo apt-get update

sudo apt-get dist-upgrade

I ran those commands the other day and then I saw a message to remove unnecessary files by running sudo apt-get autoremove.

Not a good idea.

I’ve used that command in the past (never again) without any problems. This time it broke my laravel shopping list app.

Here’s how I fixed it.

Check the file /var/log/apt/history.log by:

cat /var/log/apt/history.log

When I did, the history log showed:

Start-Date: 2023-01-13  00:21:01
Commandline: apt autoremove
Requested-By: user1 (1001)
Remove: php8.1-intl:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), php8.1-mysql:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), php8.1-xml:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), php8.1-zip:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), linux-aws-5.15-headers-5.15.0-1026:amd64 (5.15.0-1026.30~20.04.2), linux-headers-5.15.0-1026-aws:amd64 (5.15.0-1026.30~20.04.2), linux-image-5.15.0-1026-aws:amd64 (5.15.0-1026.30~20.04.2), php8.1-mbstring:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), php8.1-gd:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), linux-modules-5.15.0-1026-aws:amd64 (5.15.0-1026.30~20.04.2), php8.1-curl:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1)
End-Date: 2023-01-13  00:21:10

This showed me that the following files were removed:

php8.1-intl:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), 
php8.1-mysql:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), 
php8.1-xml:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), 
php8.1-zip:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), linux-aws-5.15-headers-5.15.0-1026:amd64 (5.15.0-1026.30~20.04.2), linux-headers-5.15.0-1026-aws:amd64 (5.15.0-1026.30~20.04.2), linux-image-5.15.0-1026-aws:amd64 (5.15.0-1026.30~20.04.2), 
php8.1-mbstring:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), 
php8.1-gd:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1), linux-modules-5.15.0-1026-aws:amd64 (5.15.0-1026.30~20.04.2), 
php8.1-curl:amd64 (8.1.14-1+ubuntu20.04.1+deb.sury.org+1)

I reinstalled these files by running:

apt install php8.1-intl
apt install php8.1-mysql
apt install php8.1-xml
apt install php8.1-zip
apt install php8.1-mbstring
apt install php8.1-gd
apt install php8.1-curl

They could also be installed all at once:

apt install php8.1-intl php8.1-mysql php8.1-xml php8.1-zip php8.1-mbstring php8.1-gd php8.1-curl

Once I reinstalled these files, all was good.

This problem occurred, in part, because when I ran the update, AWS installed php8.2.1.

Then, for whatever reason, auto remove figured I didn’t need the 8.1 extensions. Wrong.

Lesson learned.

Don’t use autoremove.

If you want to live on the edge, here’s ChatGpt explaining how to do an autoremove dry-run safely:

You can use the command “sudo apt-get autoremove –dry-run” to see a list of packages that would be removed, without actually removing them. The list of removed packages will be displayed in the terminal. Additionally, you can use “sudo apt-get autoremove -s” to simulate the autoremove process and see a list of packages that would be removed without actually removing them.

But can we really trust AI?

Visit Emlekezik.com