I'm running Oracle Linux/RHEL and trying to get a list of installed packages whose name/arch is not in any active repository. When doing yum list installed
these packages are displayed in red, but is there any yum command to only list those?
2 Answers
This is strictly for OL7:
sudo yum list installed | egrep -v "@ol7|@anaconda"
You can see all your repos by:
sudo yum list installed | grep -v "Loaded plugins" | awk '{print $3}' | sort -u

- 29,025
I'm not sure it's possible to easily answer your question for any "active repository", but we can find all packages not installed via a repository with:
awk 'NR <=3 { next; } { while (NF < 3)
{ getline more; $0=$0 more; } }
$3 !~ /^@/ { print }' \
<( yum list installed )
If you are interested in packages which are not among the currently enabled repositories, but may have been installed by ones which are active or no longer known to the system, you can do:
awk 'FNR==NR && FNR > 1 { sub(/^!/,"",$1); repos["@" $1]=1; next; }
FNR <=3 { next; } { while (NF < 3) { getline more; $0=$0 more; } }
!($3 in repos) { print }' \
<( yum repolist enabled ; echo anaconda ) \
<( yum list installed )
For awk n00bs, the FNR==NR
is an idiom to separate the first input file/stream from the rest of the inputs. That part loads the repository names into a hash, with the following caveats:
- Those repo names beginning with
!
are included, and the!
is excluded. - The
@
is prepended to the name for faster look-up when comparing against the final field in the installed-list.
Now, the complex-looking middle program simply recombines lines that yum automatically splits. As long as the input line has fewer than 3 columns/fields, append the next line to it.
The last program either tests if the third field begins with an @ or if it is in the list of repos.
Note: yum repolist enabled ; echo anaconda
appends "anaconda" to the repolist so that the packages installed at os-install time are also excluded.

- 6,138
package-cleanup --orphans
does:List installed packages which are not available from currently configured repositories.
See this answer: https://unix.stackexchange.com/a/190114 – Antoine Viallon Dec 19 '23 at 14:43yum
. The question you linked to is related purely for a particular Fedora distribution, but this one here is more general. None of my systems havepackage-cleanup
installed by default. – Otheus Dec 24 '23 at 11:21