How to get list of installed packages on Ubuntu / Debian Linux

I am a new Ubuntu Linux sysadmin. How do I get a list of all installed packages on server1 and install those on server2? How to list all installed packages using apt-get command on Ubuntu or Debian server?Learn