[root@study ~]# rpm -qa | wc -l
777
[root@study ~]# yum list installed | wc -l
1054
i want to know why different,shoud i get correct number of installed packages?
That is normal. If you install packages with RPM Yum will not know about them. It is best to install packages with yum if you want them to be managed by yum update
.
Example, CentOS 7 :
$ rpm -qa | wc -l
1733
$ yum list installed | wc -l
1757
Reason : wc
will also count the 24 "extra yum lines" ... please check with :
$ yum list installed >> yum-list-installed.txt
$ rpm -qa >> list__rpm-qa.txt
... and watch the result in the text files : Use an editor with line numbers enabled.
Note : The above commands are unprivileged user commands. No reason to use root
.