This quick post will show you how to install latest version of composer 2.x on Ubuntu 20.01 and Debian.

This also works on Windows 10 WSL 2.

Go ahead and launch terminal and run the following commands

sudo apt update

Download Composer Installer

php -r "copy('', 'composer-setup.php');"

Verify Download

php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Run Composer Installer

php composer-setup.php

Remove the Composer Installer

php -r "unlink('composer-setup.php');"

Move Composer to /usr/bin/composer

Here /aks/ is my user directory, you must replace /aks/ with your username on Debian.

 sudo mv /home/aks/composer.phar /usr/bin/composer

You have to move composer.phar to whatever folder your system says composer is not found in from the folder where composer is installed.