I'm working on a script that I want to make universal across different systems. I want to know if the command `yum update xyz` (or the equivalent `dnf` command) will actually install the package 'xyz' if it isn't already on the system, or will it just give me an error that 'xyz' cannot be found? Thanks in advance!
5 Answers
Have you actually tried it out? It shouldn't be too complicated.
I think there's a bit of confusion about the term 'universal.' Many distributions aren't based on Red Hat, which uses `yum` or `dnf`. If you're running into package management issues, maybe consider addressing those instead.
Using `yum update` or `dnf update` is mainly for updating already installed packages, not installing new ones. If you want to ensure that the application is installed, you could use a command like `yum install -y xyz` instead. It's designed to install packages if they're not present. However, if you really want to check if the package is there before trying to install it, a little one-liner like `rpm -q --quiet $NAME && yum -y update $NAME || yum install -y $NAME` would do the trick.
It really depends on whether the script you're making targets repositories that actually have the applications you want. If you package it correctly, it can be a smooth process.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures