How to save list of installed packages on Debian/Ubuntu

dpkg -l > ~/packages.txt
2018  
Popular