Linux Command Line Structure
A command in Linux is a program that instructs the system to perform a specific task. The general structure of a command is:
- command [options] [arguments]
Using Options
Options are generally preceded by a dash (-). It is possible to combine multiple options together:
- command -[option][option][option]
- ls -alR
- ls -alR
Separating Options
It is also possible to separate the options with spaces, placing a dash before each one
- ls -a -l -R
Options with Parameters
Some options require parameters. For example, to send two copies of a file to a specific printer
- lpr -Pprinter3 -#2 file
This sends 2 copies of the file to the printer named printer3
.
Exceptions
It is important to note that not all commands strictly follow these conventions. Some may not require a dash before options, and others may not allow options to be grouped.
To learn more about specific options for a command, simply consult the manual page for that command using:
- man command