Thank you. But it doesn't work for me. Is there any other way to get the result.I'm not sure there is a "one size fits all" command for this.
For example on Redhat/Fedora/CentOS you could do something like "dnf info tree | grep License"
If you wanted to list everything, you could do something like..
for i in `dnf list installed | cut -f1 -d.`; do
dnf info $i | grep License
I suspect this would take a pretty long time to run because of the recursions.
I'm not familiar enough with apt to get the equivalent, but I'm sure there is a way to do it.