Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to install packages through yum from a file?

Something like:

yum -f packages.txt

I couldn't find anything in the man pages.

packages.txt would contain something like:

share|improve this question
why rpm -ivh filename won't do it? – Hubert Kario Jan 18 '12 at 22:07
@HubertKario, yum will resolve dependencies. – cjc Jan 18 '12 at 22:25
up vote 8 down vote accepted
xargs yum -y install < filename
share|improve this answer

This works:

yum install `cat <filename> | tr '\n' ' '`

As should:

yum install `cat <filename>`

I added the pipe to tr as a sanity check, just in case the environment is wacky.

per a comment:

yum install $(cat <filename>)

will also work, rather than using the backticks.

share|improve this answer
Just tried the exact same thing - interestingly enough, it doesn't seem necessary to remove the line breaks (although, of course, it works with them removed) – cyberx86 Jan 18 '12 at 17:33
@cyberx86 - I did the tr bit out of paranoia :) – warren Jan 18 '12 at 17:34
The accepted practice nowadays is to wrap Bash shell commands with $( foo bar) instead of backticks. – Magellan Jan 18 '12 at 20:43
@AdrianK - thanks for the suggestion. I've been using backticks for a really long time ... it'll take some getting used to :) – warren Jan 18 '12 at 22:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.