Wondering How to list installed software on CentOS 7 & Ubuntu 18? We can help you.
In this article, we will see the commands to list all software, list the number of packages installed, and search for a specific package.
Also, we will add installed software on a text file, and later install the software from the text file.
Here at Bobcares, we use these commands often as a part of our Server Management Services.
How to list installed software on CentOS 7 & Ubuntu 18
We will use a file to store a list of all currently installed software named “allsoftwares.txt”
Incase of reinstalling the base Linux system, we can copy or upload this file into the system so that we will get all the software that existed before formatting the system.
Here go through the commands used by our Support Techs to list installed software on CentOS7 and Ubuntu18.
Commands used for CentOS7
Yum and rpm are commonly used on CentOS 7 servers.
1. Using RPM
To List all software:
[root@host ~]# rpm -qa
For listing the number of packages installed:
[root@host ~]# rpm -qa | wc -l
To search for a specific package:
[root@host ~]# rpm -q tmux
Adding installed software to a text file:
[root@host ~]# rpm -qa | tr '\n' ' ' > allsoftwares.txt
2. Using YUM
To list all software:
[root@host ~]# yum list installed
For listing the number of packages installed:
[root@host ~]# yum list installed | wc -l
To search for a specific package:
[root@host ~]# yum list installed | grep unzip
Adding installed software to a text file:
[root@host ~]# yum list installed | awk '{print $1}' | tr '\n' ' ' > allsoftwares.txt
Install software from the text file:
[root@host ~]# yum -y install $(cat allsoftwares.txt)
Commands used for Ubuntu18
Apt and dpkg are commonly used on Ubuntu servers
1. Using APT
To list all software:
[root@host ~]# apt list --installed
For listing the number of packages installed:
[root@host ~]# apt list --installed | wc -l
To search for a specific package:
[root@host ~]# apt list --installed | grep PHP
Adding installed software to a text file:
[root@host ~]# apt list --installed > allsoftwares.txt
Or
[root@host ~]# apt list --installed | awk -F/ -v ORS=" " 'NR>1 {print $1}' > allsoftwares.txt
Installing software from the text file:
[root@host ~]# xargs -a allsoftwares.txt apt install
2. Using DPKG
To list all software:
[root@host ~]# dpkg -l | grep ^ii
For listing the number of packages installed:
[root@host ~]# dpkg -l | grep ^ii | wc -l
To search for a specific package:
[root@host ~]# dpkg -l | grep ^ii | grep -i PHP
Adding installed software to a text file:
[root@host ~]# dpkg-query -f '${binary:Package}\n' -W > allsoftwares.txt
or
[root@host ~]# dpkg --get-selections > allsoftwares.txt
Installing software from the text file:
[root@host ~]# apt-get install < allsoftwares.txt
[Need assistance? We are happy to help you!]
Conclusion
To conclude we saw the various commands our Support Engineers use to list all software, the number of packages available on the server along with the method to copy them and use them when we reinstall our operating system(OS).
0 Comments