Options and Arguments in Linux

Published: December 07, 2022

Last updated: December 07, 2022

Options and Arguments in Linux

In this article, we cover command-line options and arguments in Linux. A command-line interface (CLI) is a text-based user interface through which we can manage our system resources. We mainly utilize various command-line utilities to get things done through a Shell. Have you ever noticed that outcome of standalone commands is different from the outcome when such commands are used with various options and arguments. For instance, open a terminal and issue the following command -


Now, with -l option

ls -l

Lastly, with an argument that could be a <file-name>

ls -l abc.txt

Notice, how different outcomes we get.

Options and Arguments in Linux

Clearly, options and arguments help further enhance/customize the outcome. The following syntax is used for a Linux command -

Command [options] [arguments]

where, options are generally preceded by a one or more hyphens. And, arguments could be a file or directory on which we perform an action through our command.

We can also combine multiple options which are preceded by single hyphen -

ls -al

While, we generally use a word for long options which are preceded by two hyphens -

ls --all

Ideally, arguments should be entered after we have specified command-line options. As already covered, arguments could a filename or a directory name -

ls abc.txt

Or, we can also use both options and arguments as well -

ls -l abc.txt

In conclusion, we have covered here command-line options and arguments in Linux.

Additional Info -

If you would like to know more about a specific command then use man pages. man pages basically help a user utilize a command effectively. There are numerous options for a command which we can't cover here. Apart from that, there could be specific use cases which won't get covered as well.

So, it is better to go through the man pages at least once. Use the following syntax -

man <command>

For instance, for ls command -

man ls