0%

Linux: some useful command of yum

Yum is a very powful tool in Redhat Linux, it can provide install and update software online.

Some very useful commands

Quiry

1
yum list all

query all softwares in repository

1
yum list installed

softwares already installed on host

1
yum list available

softwares not installed yet, you can install right now

1
yum list updates

show the software that can be updated at once

The following two commands have same function

1
2
yum provides passwd
rpm -qf /etc/passwd

Both will tell you what software this command belong to

Yum config documents location

/etc/yum.repo.d/
/etc/yum.conf

About groupinstall

If you want to install a group software, for example,

1
2
yum groupinfo "Scientific Support"
Yum groupinstall "Scientific Support"

It will show error

1
2
3
4
5
6
7
8
9
10
11
12
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.fileplanet.com
* extras: mirror.fileplanet.com
* updates: mirror.fileplanet.com
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
ftp.ksu.edu.tw_FTP_CentOS_7_os_x86_64_ | 3.6 kB 00:00:00
updates | 3.4 kB 00:00:00
Warning: Group scientific does not have any packages to install.
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update

You need to add “group_package_types=default,mandatory,optional” to configuration file.

1
vim /etc/yum.conf
1
group_package_types=default,mandatory,optional

After doing that, you can install the group software successfully.

Add baseurl to your yum repository

1
yum-config-manager --add-repo=http://www.centos.ann
1
2
3
4
[centos.ann]
name=added from: http://www.centos.ann
baseurl=http://www.centos.ann
enabled=1

It will appear to list /var/cache/yum/x86_64/7

1
2
cd /var/cache/yum/x86_64/7
ll
1
drwxr-xr-x. 4 root root   33 Mar  8 11:13 centos.ann
1
yum repolist
1
2
3
repo id                                 repo name                                                  status
base/7/x86_64 CentOS-7 - Base 10,019
centos.ann added from: http://www.centos.ann 0

It shows centos.ann is the default yum base. 0 means there is no software in it.

Use local disk or CD to yum software

1
vim /etc/yum.repos.d/cdrom.repo
1
2
3
4
[CDROM]
name=cdrom
baseurl=file:///mnt
enable=1
1
yum --enablerepo=cdrom

In case the rpm verify, you need to add pki

1
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7