You can use dpkg to list all the packages that are selected on your Debian or Ubuntu system:

# dpkg --get-selections

But today I needed a way to list only the installed packages in just one line, so I could copy their names and use apt-get to install the same packages on another system. So I used the following command: