yum update if installed, otherwise install
5,834
At least for me, yum
is bright enough that if I tell it to install something which is already installed, and for which an update is available, it will just apply the update instead. E.g.:
[root@risby ~]# rpm -qa|grep openvpn
openvpn-2.2.2-7.fc17.x86_64
openvpn is installed.
[root@risby ~]# yum update
[...]
--> Running transaction check
---> Package openvpn.x86_64 0:2.2.2-7.fc17 will be updated
---> Package openvpn.x86_64 0:2.3.1-2.fc17 will be an update
An update is available.
[root@risby ~]# yum install openvpn
[...]
--> Running transaction check
---> Package openvpn.x86_64 0:2.2.2-7.fc17 will be updated
---> Package openvpn.x86_64 0:2.3.1-2.fc17 will be an update
yum install
does the right thing anyway. yum version is 3.4.3, by the way.
Related videos on Youtube
Author by
John Smith Optional
Updated on September 18, 2022Comments
-
John Smith Optional almost 2 years
Is there a command to do just that: if a package is already installed, update it, otherwise install the latest version
For now I'm doing two commands:
yum install mypackage yum update mypackage
Maybe there's a more efficient way?
-
John Smith Optional about 11 yearsI observed this behavior of yum a few times, but since I haven't found it documented anywhere, I wonder if I can rely on it.
-
Michael Hampton almost 5 years@proteantech Try something a little less ancient. That version of yum is from 2009; while this question and yum version is from 2013.