I know how to use rpm to list the contents of a package (rpm -qpil package.rpm). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM. How can YUM be used to achieve this?
There is a package called yum-utils that builds on YUM and contains a tool called repoquery that can do this.
$ repoquery --help | grep -E "list\ files"
-l, --list list files in this package/group
Combined into one example:
$ repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
On at least one RH system, with rpm v4.8.0, yum v3.2.29, and repoquery v0.0.11, repoquery -l rpm prints nothing.
If you are having this issue, try adding the --installed flag: repoquery --installed -l rpm.
DNF Update:
To use dnf instead of yum-utils, use the following command:
$ dnf repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
rpm -ql [packageName]
Example
# rpm -ql php-fpm
/etc/php-fpm.conf
/etc/php-fpm.d
/etc/php-fpm.d/www.conf
/etc/sysconfig/php-fpm
...
/run/php-fpm
/usr/lib/systemd/system/php-fpm.service
/usr/sbin/php-fpm
/usr/share/doc/php-fpm-5.6.0
/usr/share/man/man8/php-fpm.8.gz
...
/var/lib/php/sessions
/var/log/php-fpm
No need to install yum-utils, or to know the location of the rpm file.
$ yum install -y yum-utils
$ repoquery -l packagename
I don't think you can list the contents of a package using yum, but if you have the .rpm file on your local system (as will most likely be the case for all installed packages), you can use the rpm command to list the contents of that package like so:
rpm -qlp /path/to/fileToList.rpm
If you don't have the package file (.rpm), but you have the package installed, try this:
rpm -ql packageName
There are several good answers here, so let me provide a terrible one:
: you can type in anything below, doesnt have to match anything
yum whatprovides "me with a life"
: result of the above (some liberties taken with spacing):
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/4): extras/7/x86_64/primary_db | 166 kB 00:00
(2/4): base/7/x86_64/group_gz | 155 kB 00:00
(3/4): updates/7/x86_64/primary_db | 9.1 MB 00:04
(4/4): base/7/x86_64/primary_db | 5.3 MB 00:05
Determining fastest mirrors
* base: mirrors.xmission.com
* extras: mirrors.xmission.com
* updates: mirrors.xmission.com
base/7/x86_64/filelists_db | 6.2 MB 00:02
extras/7/x86_64/filelists_db | 468 kB 00:00
updates/7/x86_64/filelists_db | 5.3 MB 00:01
No matches found
: the key result above is that "primary_db" files were downloaded
: filelists are downloaded EVEN IF you have keepcache=0 in your yum.conf
: note you can limit this to "primary_db.sqlite" if you really want
find /var/cache/yum -name '*.sqlite'
: if you download/install a new repo, run the exact same command again
: to get the databases for the new repo
: if you know sqlite you can stop reading here
: if not heres a sample command to dump the contents
echo 'SELECT packages.name, GROUP_CONCAT(files.name, ", ") AS files FROM files JOIN packages ON (files.pkgKey = packages.pkgKey) GROUP BY packages.name LIMIT 10;' | sqlite3 -line /var/cache/yum/x86_64/7/base/gen/primary_db.sqlite
: remove "LIMIT 10" above for the whole list
: format chosen for proof-of-concept purposes, probably can be improved a lot
currently reopquery is integrated into dnf and yum, so typing:
dnf repoquery -l <pkg-name>
will list package contents from a remote repository (even for the packages that are not installed yet)
meaning installing a separate dnf-utils or yum-utils package is no longer required for the functionality as it is now being supported natively.
for listing installed or local (*.rpm files) packages' contents there is rpm -ql
i don't think it is possible with yum org dnf (not repoquery subcommand)
please correct me if i am wrong
Yum doesn't have it's own package type. Yum operates and helps manage RPMs. So, you can use yum to list the available RPMs and then run the rpm -qlp command to see the contents of that package.
Related
I would like to find difference between installed xyz-1.0.rpm & latest available xyz-1.1.rpm on repository. Also would like to find out any file change happened in new rpm. How can I do that?
please help.
Thanks
check the changelog
You can check the changelog file:
make sure that you have the package yum-plugin-changelog
and then you can use this command to print the last (most recent) changelog message for the xyz package
# yum changelog 1 xyz | less
otherwise you can use rpm:
# rpm -q --changelog -p xyz-1.0.rpm | less
# rpm -q --changelog -p http://mirror.centos.org/centos/6/os/x86_64/Packages/xyz-1.1.rpm | less
compare the files list
to List Files inside the rpm:
Download xyz-1.1.rpm and list files in xyz-1.1.txt
# rpm -qlp xyz-1.1.rpm > xyz-1.1.txt
then list file of the installed package xyz-1.0.rpm
# rpm -ql xyz > xyz-1.0.txt
and finally:
# diff xyz-1.0.txt xyz-1.1.txt
;)
yum check-update
This command allows you to determine whether any updates are available for your installed packages. yum returns a list of all package updates from all repositories if any are available.
https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-yum-useful-commands.html
You check the latest version of the as mentioned above using yum check-update and check the version of the installed rpm: rpm -qa | grep mypackage.
Next obtain the a copy of the current rpm and new rpm using yumdownloader (you may need to use sudo as some TLS certs may only be accessible to root) e.g:
sudo yumdownloader mypackage-current.version
sudo yumdownloader mypackage-latest.version
Then install pkgdiff: sudo yum install pkgdiff and run it to generate an HTML report on the differences:
pkgdiff mypackage-current.version mypackage-latest.version
Purpose
I'm trying to install mongodb on EC2 AWS x86_64 GNU/Linux via Yum.
Prerequisites
I created a /etc/yum.repos.d/mongodb.repo file and tried all the available combinations for it's content found on the official documentations and on the related questions on stackoverflow link1 link2 link3, for example:
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
(...tried with enabled=0, gpgcheck=0 too)
I also added a /etc/yum.conf file like this:
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
Problem
I'm getting the same output when running
sudo yum install mongodb-org (or by specifying the packages sudo yum install mongo-org mongo-org-server or by specifying the versions too sudo yum install -y mongodb-org-3.2.13 mongodb-org-server-3.2.13 mongodb-org-shell-3.2.13 mongodb-org-mongos-3.2.13 mongodb-org-tools-3.2.13)
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
No package mongodb-org available.
Error: Nothing to do
Question
What am I missing? Is there any additional dependencies?
You don't need to create a new /etc/yum.repos.d/mongodb.repo or at the time of this answer /etc/yum.repos.d/mongodb-org-3.6.repo cause it already exists but it is empty.
You can check with: cat /etc/yum.repos.d/mongodb-org-3.6.repo.
all you need to do is open the file on vi editor:
$ sudo vi /etc/yum.repos.d/mongodb-org-3.6.repo
~
~
add this code to the repository file. The one i provided is for the MongoDB 3.6 but you can find the one for earlier versions in the documentation:
[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
To save and exit from vi editor check here or go ahead and do this:
ESC + :wq
After that you can proceed with the steps in the documentation or in the old C9 Forum, but here they are just in case:
$ sudo yum install -y mongodb-org
$ sudo mkdir -p /data/db
$ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$#"' > mongod
$ chmod a+x mongod
You can start mongodb by running the mongod script on your project root:
$ ./mongod
The last command might not run the mongodb local server, and you can find the solution for that here or just go ahead and run these two commands:
$ sudo service mongod stop
$ sudo mongod
The only error I can spot is the space in "name" :
name=MongoDB Repository
With the naming changed to name=MongoDB, I did a test with CenOS 7 :
# yum search mongodb-org
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
.
mongodb-org-3.4 | 2.5 kB 00:00
updates | 3.4 kB 00:00
(1/5): mongodb-org-3.4/primary_db | 30 kB 00:00
.
=========================== N/S matched: mongodb-org ============
mongodb-org-debuginfo.x86_64 : Debug information for package mongodb-org
mongodb-org.x86_64 : MongoDB open source document-oriented database system
: (metapackage)
mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router
mongodb-org-server.x86_64 : MongoDB database server
mongodb-org-shell.x86_64 : MongoDB shell client
mongodb-org-tools.x86_64 : MongoDB tools
So I guess you can now install ``mongodb-org´´.
The problem was that I wanted to do it from the default ec2_user/ home folder. You need to cd .. up to the root, and locate the etc/yum.repos.d/ folder there.
For those of you finding this error after running an ARM AMI Linux 2 image, simply install the RPMs directly from the testing repository, which is the only one that supports all binaries on Amazon AArch64:
https://repo.mongodb.org/yum/amazon/2/mongodb-org/testing/aarch64/RPMS/
For example, to install the latest mongo shell:
sudo yum install -y https://repo.mongodb.org/yum/amazon/2/mongodb-org/testing/aarch64/RPMS/mongodb-org-shell-4.4.4-0.1.rc1.amzn2.aarch64.rpm
There is a dedicated repository for AWS Linux now.
Follow the instructions from https://docs.mongodb.com/master/tutorial/install-mongodb-on-amazon/
e.g.
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
I had this happen when my install commands specified sudo yum install mongodb-org-tools-4.0.18, but yum list available | grep mongo showed only 3.6 was available. So I did sudo yum install mongodb-org-tools and that worked.
I think you try to add exclude directory from /etc/yum.conf to prevent future updates
for example:
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
But above line need to be added after perform install mongodb-org:
sudo yum install -y mongodb-org
Is there a way to list the 3rd party softwares installed in Centos?
I have tried using rpm -qa
but it contains the native packages also.
I am looking for something similar like Installed section in "Software Center in GUI mode" in CLI mode.
I do not have CentOS install. So I will show it how I will do that on my Fedora:
$ rpm -qi rpm |grep Vendor
Vendor : Fedora Project
This will get me who is vendor of rpm package. You may have there something like CentOS. Get that string. And then:
$ rpm -qa --qf '%{name} %{vendor}\n' | grep -v 'Fedora Project'
This will print all installed packages which are not from vendor "Fedora Project".
I tried using the following commands. However when I reach the last step to install pdftk the console is giving me the error below. I am using a hostgator VPS server. any possible suggestions would be great.
NB: I tried installing libgcj.so.7rh()(64bit) but it already exists. maybe I am doing something wrong.
**Error:** Package: pdftk-1.44-2.el5.rf.x86_64 (rpmforge)
Requires: libgcj.so.7rh()(64bit)
You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
sendmail-cf-8.14.4-8.el6.noarch has missing requires of sendmail = ('0', '8.14.4', '8.el6')
These are the steps that I followed.
# Log in as root
cd /usr/local/src
# Type
uname -i
#To see which package you need
#Pick one of the below vdepending on the output of uname -i
i386<br>
wegt packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
x86_64 <br>
wget packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
#Then type
rpm --import apt.sw.be/RPM-GPG-KEY.dag.txt
Verify the downloaded package
rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
#Install RPM
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
#Then
yum install pdftk
Note: I had to remove the http:// from the links in the commands above before posting.
It seems like you might have a 32-bit OS installed? If you ran through each of those commands in order, you would be trying to use the 64-bit rpmforge repository, which is incorrect for a 32-bit OS.
If that is an accurate supposition, do this..
cd /etc/yum.repos.d/
ls -al
rm <each-rpmforge-file>
Then...
cd /usr/local/src
yum clean
wget packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
yum update
yum install pdftk
I have built two RPM packages
proj1-1.0-1.x86_64.rpm
libtest1-1.0-1.x86_64.rpm
proj1 depends on the file libtest1.so being present and it is reflected correctly in the RPM packages as seen here:
user#my-pc:~$ rpm -qp --requires proj1-1.0-1.x86_64.rpm
libtest1.so()(64bit)
user#my-pc:~$ rpm -qp --provides libtest1-1.0-1.x86_64.rpm
libtest1.so()(64bit)
The installation of proj1 fails due to a missing dependency.
user#my-pc:~$ rpm -ivh proj1-1.0-1.x86_64.rpm
error: Failed dependencies:
libtest1.so()(64bit) is needed by proj1-1.0-1.x86_64.rpm
How do I ensure that libtest1-1.0-1.x86_64.rpm is installed automatically during
the installation of proj1-1.0-1.x86_64.rpm?
I did try the --aid option with rpm -i as described here but it didn't work for me.
Is there any other way?
Thanks for any help.
The link #gertvdijk provided shows a quick way to achieve the desired results without configuring a local repository:
$ yum --nogpgcheck localinstall packagename.arch.rpm
Just change packagename.arch.rpm to the RPM filename you want to install.
Edit Just a clarification, this will automatically install all dependencies that are already available via system YUM repositories.
If you have dependencies satisfied by other RPMs that are not in the system's repositories, then this method will not work unless each RPM is also specified along with packagename.arch.rpm on the command line.
Create a (local) repository and use yum to have it resolve the dependencies for you.
The CentOS wiki has a nice page providing a how-to on this. CentOS wiki HowTos/CreateLocalRepos.
Summarized and further minimized (not ideal, but quickest):
Create a directory for you local repository, e.g. /home/user/repo.
Move the RPMs into that directory.
Fix some ownership and filesystem permissions:
# chown -R root.root /home/user/repo
Install the createrepo package if not installed yet, and run
# createrepo /home/user/repo
# chmod -R o-w+r /home/user/repo
Create a repository configuration file, e.g. /etc/yum.repos.d/myrepo.repo containing
[local]
name=My Awesome Repo
baseurl=file:///home/user/repo
enabled=1
gpgcheck=0
Install your package using
# yum install packagename
For dnf users just use dnf install *.rpm, localinstall is no longer needed.
For me worked just with
# yum install ffmpeg-2.6.4-1.fc22.x86_64.rpm
And automatically asked authorization to dowload the depedencies.
Below the example, i am using fedora 22
[root#localhost lukas]# yum install ffmpeg-2.6.4-1.fc22.x86_64.rpm
Yum command has been deprecated, redirecting to '/usr/bin/dnf install ffmpeg-2.6.4-1.fc22.x86_64.rpm'.
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'
Last metadata expiration check performed 0:28:24 ago on Fri Sep 25 12:43:44 2015.
Dependencies resolved.
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
SDL x86_64 1.2.15-17.fc22 fedora 214 k
ffmpeg x86_64 2.6.4-1.fc22 #commandline 1.5 M
ffmpeg-libs x86_64 2.6.4-1.fc22 rpmfusion-free-updates 5.0 M
fribidi x86_64 0.19.6-3.fc22 fedora 69 k
lame-libs x86_64 3.99.5-5.fc22 rpmfusion-free 345 k
libass x86_64 0.12.1-1.fc22 updates 85 k
libavdevice x86_64 2.6.4-1.fc22 rpmfusion-free-updates 75 k
libdc1394 x86_64 2.2.2-3.fc22 fedora 124 k
libva x86_64 1.5.1-1.fc22 fedora 79 k
openal-soft x86_64 1.16.0-5.fc22 fedora 292 k
opencv-core x86_64 2.4.11-5.fc22 updates 1.9 M
openjpeg-libs x86_64 1.5.1-14.fc22 fedora 89 k
schroedinger x86_64 1.0.11-7.fc22 fedora 315 k
soxr x86_64 0.1.2-1.fc22 updates 83 k
x264-libs x86_64 0.142-12.20141221git6a301b6.fc22 rpmfusion-free 587 k
x265-libs x86_64 1.6-1.fc22 rpmfusion-free 486 k
xvidcore x86_64 1.3.2-6.fc22 rpmfusion-free 264 k
Transaction Summary
====================================================================================================================
Install 17 Packages
Total size: 11 M
Total download size: 9.9 M
Installed size: 35 M
Is this ok [y/N]: y
I found a simpler solution. If you have all the RPMs in the same directory, all you need to do is,
$ sudo rpm -i *.rpm
rpm seems to figure out the correct order to install these and installs the RPMs.
Matthew's answer awoke many emotions, because of the fact that it still lacks a minor detail.
The general command would be:
# yum --nogpgcheck localinstall <package1_file_name> ... <packageN_file_name>
The package_file_name above can include local absolute or relative path, or be a URL (possibly even an URI).
Yum would search for dependencies among all package files given on the command line AND IF IT FAILS to find the dependencies there, it will also use any configured and enabled yum repositories.
Neither the current working directory, nor the paths of any of package_file_name will be searched, except when any of these directories has been previously configured as an enabled yum repository.
So in the OP's case the yum command:
# cd <path with pkg files>; yum --nogpgcheck localinstall ./proj1-1.0-1.x86_64.rpm ./libtest1-1.0-1.x86_64.rpm
would do, as would do the rpm:
# cd <path with pkg files>; rpm -i proj1-1.0-1.x86_64.rpm libtest1-1.0-1.x86_64.rpm
The differencve between these yum and rpm invocations would only be visible if one of the packages listed to be installed had further dependencies on packages NOT listed on the command line.
In such a case rpm will just refuse to continue, while yum would use any configured and enabled yum repositories to search for dependencies, and may possibly succeed.
The current working directory will NOT be searched in any case, except when it has been previously configured as an enabled yum repository.
Copy all your RPMs in a directory, then install as follows:
yum install -y --cacheonly --disablerepo=* /var/rpm_dir/*.rpm
For specific packages you can use yumdownloader, example in this other thread: https://stackoverflow.com/a/66927190/5078874
I ran into this and what worked for me was to run yum localinstall enterPkgNameHere.rpm from inside the directory where the .rpm file is located.
Note: replace the enterPkgNameHere.rpm with the name of your .rpm file.
In the case of openSUSE Leap 15, I'm receiving similar error:
> sudo rpm -i opera-stable_53.0.2907.68_amd64.rpm
[sudo] password for root:
warning: opera-stable_53.0.2907.68_amd64.rpm: Header V4 RSA/SHA512 Signature, key ID a5c7ff72: NOKEY
error: Failed dependencies:
at is needed by opera-stable-53.0.2907.68-0.x86_64
I run this command to figure out what are the dependencies:
> sudo zypper install opera-stable_53.0.2907.68_amd64.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 4 NEW packages are going to be installed:
at libfl2 libHX28 opera-stable
4 new packages to install.
Overall download size: 50.3 MiB. Already cached: 0 B. After the operation, additional 176.9 MiB will be used.
Continue? [y/n/...? shows all options] (y): n
Then I run this command to install dependencies:
> sudo zypper in at
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 3 NEW packages are going to be installed:
at libfl2 libHX28
3 new packages to install.
Overall download size: 208.6 KiB. Already cached: 0 B. After the operation, additional 600.4 KiB will be used.
Continue? [y/n/...? shows all options] (y): y
Then I run this to install the rpm file:
> sudo rpm -i opera-stable_53.0.2907.68_amd64.rpm
I'm not sure if it is the best practice, however it solved my issue.
Step1: copy all the rpm pkg in given locations
Step2: if createrepo is not already installed, as it will not be by default, install it.
[root#pavangildamysql1 8.0.11_rhel7]# yum install createrepo
Step3: create repository metedata and give below permission
[root#pavangildamysql1 8.0.11_rhel7]# chown -R root.root /scratch/PVN/8.0.11_rhel7
[root#pavangildamysql1 8.0.11_rhel7]# createrepo /scratch/PVN/8.0.11_rhel7
Spawning worker 0 with 3 pkgs
Spawning worker 1 with 3 pkgs
Spawning worker 2 with 3 pkgs
Spawning worker 3 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root#pavangildamysql1 8.0.11_rhel7]# chmod -R o-w+r /scratch/PVN/8.0.11_rhel7
Step4: Create repository file with following contents at /etc/yum.repos.d/mysql.repo
[local]
name=My Awesome Repo
baseurl=file:///scratch/PVN/8.0.11_rhel7
enabled=1
gpgcheck=0
Step5 Run this command to install
[root#pavangildamysql1 local]# yum --nogpgcheck localinstall mysql-commercial-server-8.0.11-1.1.el7.x86_64.rpm
Simple just run the following command.
sudo dnf install *package.rpm
Enter your password and you are done.
Process of generating RPM from source file:
1) download source file with.gz extention.
2) install rpm-build and rpmdevtools from yum install. (rpmbuild folder will be generated...SPECS,SOURCES,RPMS.. folders will should be generated inside the rpmbuild folder).
3) copy the source code.gz to SOURCES folder.(rpmbuild/SOURCES)
4)Untar the tar ball by using the following command.
go to SOURCES folder :rpmbuild/SOURCES where tar file is present.
command: e.g tar -xvzf httpd-2.22.tar.gz
httpd-2.22 folder will be generated in the same path. Check if apr and apr-util and there in httpd-2.22/srclib folder. If apr and apr-util doesnt exist download latest version from apache site ,untar it and put it inside httpd-2.22/srclib folder. Also make sure you have pcre install in your system .
5)go to extracted folder and then type below command:
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-proxy --enable-proxy-balancer --with-mpm=worker --enable-mods-static=all
6)run below command once the configure is successful:
make
7)after successfull execution od make command run:
checkinstall
in tha same folder. (if you dont have checkinstall software please download latest version from site)
Also checkinstall software has bug which can be solved by following way:::::
locate checkinstallrc and then replace TRANSLATE = 1 to TRANSLATE=0 using vim command.
Also check for exclude package: EXCLUDE="/selinux"
8)checkinstall will ask for option (type R if you want tp build rpm for source file)
9)Done .rpm file will be built in RPMS folder inside rpmbuild/RPMS file...
ALL the BEST ....
Regards,
Prerana