how to remove unnecessary packages in linux

Shell
sudo apt autoremove --purge
sudo apt-get clean
Source

Also in Shell: