How can I completely uninstall LAMP installed in the Ubuntu 18.04 which is running in the VM, from the code I like to remove and make completely free now.
Assuming you are removing the "AMP" from the "LAMP" (you wouldn't like to remove the Linux, too), the following should work in most cases. The first command removes Apache, MySQL and PHP. The rest cleans up the packages that were only required by these packages. The
purge removes all the configuration files, too; if you wish to preserve the configuration, use
sudo apt-get purge apache2 mysql-server php sudo apt autoremove sudo apt autoclean