Here is how to list all installed packages on SSH on deb GNU/Linux including Debian and Ubuntu Servers over SSH. New users frequently need it as they forget what or which tutorial or guide they followed. It is not uncommon to read our one guide for one part, then searching for another thing on Google and following another person’s guide. It can happen that, one package was installed, but that is not needed anymore.
List All Installed Packages on SSH (Ubuntu/deb GNU/Linux)
Copy paste this command on any text editor first, then copy to SSH and hit the return key :
( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline:'
copy-pasting will evoke the webpage’s URL to get copied to protect contact-theft, that is why; copy on text editor first. We kept another way to to execute the command, here is a gist file of the command as bash script. You will only run these commands :
chmod +x packages.sh
Against the command, you’ll get this list :
This has security advantages too – it list the commands you typed to install or update the system. In case, you want the date of the works too, this modified command will work fine :
( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; \
cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep -B1 '^Commandline:'
You’ll get list like this :
Commandline: apt-get autoremove
Start-Date: 2015-05-22 01:34:32
Commandline: apt-get purge --auto-remove memcached php5-memcache
Start-Date: 2015-05-22 01:39:47
Commandline: apt-get purge --auto-remove monit rmon
We are getting the data from the log files, not apt. It is risk free for a running server. We have a separate gist for it on Github.
How I Will Handle the List of All Installed Packages on SSH
Suppose, you want to see all the works with xcache, then it is better to use the script :
wget https://gist.githubusercontent.com/AbhishekGhosh/45a209e6cb44dd8c9c9d/raw/9ba95b404eebd7d1721c4eb6439cc3767c84f145/packages-date.sh && chmod +x packages-date.sh
sh packages-date.sh | grep xcache
Now, you can replace whatever you are searching for with
xcache after grep command to find it. This are the official commands :
dpkg --get-selections | grep -v deinstall
aptitude search '~i!~M'
the above are not exactly what people want over SSH. We want our manual work, not the dependencies got installed o system installed. We have not discovered the commands and we do not need to know who discovered the commands. They serve the purpose, that is enough.Tagged With GNU linux list packages installed , list installed packages GNU/linux , ubuntu list all installed packages , ubuntu list packages installed