Metasploitable3 by rapid7 is an environment built for testing metapsploit. Unfortunately, it hasn't been updated in many years and the default instructions on their page are wrong.
This walkthrough is based on Ubuntu 22.04, so subject to change.
Official page here: https://github.com/rapid7/metasploitable3
Install vagrant
. Follow the instructions on their page for the most up-to-date details for your distro: