I need to create a table with all installable packages on first column and its license in the second.
e.g.:
- Gedit | GPL
Apt doesn't really support licencing queries like that but you always try aptitude -F "%p %s" search "?not(?installed)"
That will tell you what section of the repository it's in.
There is also
packages=
dpkg --get-selections | awk '{ print $1 }'
for package in $packages; do echo "$package: "; cat /usr/share/doc/$package/copyright;echo ""; echo ""; done > ~/licenses.txt
From This Question