How do I find what packages I've installed via terminal?
Since OS X has no package manager, anything you install would have been manual, through MacPorts or through Installer.

If you want a list of the binaries your terminal has access to, you can run the following commands to check the most common spots, and output the result as a text file:

touch ~/Binaries.txt
ls /usr/bin &gt; ~/Binaries.txt
ls /usr/sbin &gt;&gt; ~/Binaries.txt
ls /usr/local/bin &gt;&gt; ~/Binaries.txt
ls /usr/local/sbin &gt;&gt; ~/Binaries.txt
ls /opt/local/bin &gt;&gt; ~/Binaries.txt
ls /opt/local/sbin &gt;&gt; ~/Binaries.txt


Alternatively, if you just want to get the packages installed by MacPorts, run the following (this is probably the one you want):

touch ~/MacPorts.txt
port installed &gt; ~/MacPorts.txt


And for Homebrew:

touch ~/HomeBrew.txt
brew list &gt; ~/HomeBrew.txt


And finally, for all packages installed by Installer

touch ~/InstalledPackages.txt
pkgutil --packages &gt; ~/InstalledPackages.txt


To restore, for example, your MacPorts ports from the list generated above, use the following:

 port install $(cat ~/MacPorts.txt)