Question: Does it matter which order options are entered when using the command line?

The following example comes from CentOS. Would these two commands produce the same result?

sudo yum update -y

sudo yum -y update

Is there a page that explains the general syntax rules for the command line? I can't seem to find one that explains if/how order impacts outcome. Thanks so much in advance!


That does entirely depend on the program and sometimes the type of parameter. In your example, it doesn't matter, but there exist programs that needs parameters in a certain order. Also, even with yum as an example, yum install somepackage would work but yum somepackage install would not.

When in doubt, consult the documentation of the program in question (e.g. man yum).

  • Thanks! As long as I know each program may be a little different that's a rule I can remember. – DR01D Jan 26 '18 at 15:56

There is no specific rules for this case. Parameter -y means, that you answer "Yes" to any questions. From yum manpage:

-y, --assumeyes

Assume yes; assume that the answer to any question which would be asked is yes.

Usage of yum: yum [options] [command] [package ...]

But you may put options anywhere you want:

yum install -y nagios-plugins-perl.x86_64 -e 1 nagios-plugins-ifstatus.x86_64

where -e 1 - debug level

This command will work properly due to argument parsing.

  • Does CentOS know to apply the -y to yum and not to update? – DR01D Jan 26 '18 at 15:52
  • 1
    @DR01D: The OS (or better the shell starts yum and sends it the parameters which where used when starting it. It's only the job of the program to make sense of these parameters, the shell doesn't care at all. – Sven Jan 26 '18 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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