Today, it's about a simple task: switching PHP versions on the command line in Ubuntu:

sudo update-alternatives --set php /usr/bin/php8.1

It works the same for the other PHP commands:

sudo update-alternatives --set phar /usr/bin/phar8.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.1
sudo update-alternatives --set phpize /usr/bin/phpize8.1
sudo update-alternatives --set php-config /usr/bin/php-config8.1