Is there a way to add and remove packages at the same time with a single yum command? For example, installing postfix and removing sendmail without running two separate commands/transactions.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Yes. Invoking yum shell will allow you to specify multiple commands that will happen simultaneously when run is entered.
Method 2
Newer versions of yum also have the swap command:
# yum swap -- install foo -- remove bar
Method 3
As the accepted answer already says, you can use yum shell to run multiple commands at once, which is fine for interactive use. But if you want to invoke this command from a script, you can also run it against a file, eg yum shell translist.txt, where the file could contain, for example:
remove squid install squid34 run
Append the -y switch to assume yes to confirmation prompts.
Method 4
sudo yum swap postfix sendmail
Although the O/P has his answer, I’m leaving this short one for people who need this in the future
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0