Lesson 2.2: Command line arguments and options
The grammar of a command line: command name, options (short, long, combined, with values) and arguments; hidden files. Lab: ls with -l, -a, -la, --all, head -n and uname -sr.
16 min
You will learn to
- Split a command line into command, options and arguments
- Use short, long and combined options
- Give an option a value (head -n 3)
- Show hidden files and explain what makes a file hidden
Key terms
- Argument
- A word after the command that tells it what to work on: usually a file, a folder or a piece of text.
- Option (flag, switch)
- A word starting with a dash that changes how the command behaves.
- Short and long options
- Short options are one letter after one dash (-a); long options are whole words after two dashes (--all). Many options exist in both forms.
- Combined options
- Several short options can share one dash: -la is the same as -l -a.
- Option value
- Some options need a value right after them.
- Hidden file (dot file)
- A file whose name starts with a dot. ls doesn't show it unless you ask with -a. Programs keep their settings in such files.
← Introduction to the command line · All lessons · Getting help on the command line →