There are two interfaces to manage a Linux system: CLI and GUI. CLI is faster than GUI. But on the flip side, it is more complex than CLI. On CLI, we use commands to manage system configuration and file system.
Commands, arguments, and options
A command has three parts: the command, options, and arguments. From these, the command is compulsory while options and arguments are optional.
Command
A Linux shell includes commands, configurations, and system settings. It provides a prompt, called a command prompt, to enter commands. When we hit the Enter key after typing a word on the command prompt, the shell interprets it as a command. It finds a file or a script whose name matches the typed word in pre-defined directories. To view the pre-defined directories, you use the following command.
$echo $PATH
If it finds a matching script, it executes the script. If it does not find a matching file or script, it returns an error command not found. Let's understand it through examples. Execute the following commands on the command prompt.
$ls $list
The shell has a script file named ls, but it does not have any file or script named list. Since it has a script file named ls, it executes the first command and returns an error for the second command.
Options
Options modify the default behavior of the command. Generally, they are used to change the output. They are optional. They are also known as switches. Some options are used without a hyphen sign. Some are used with a single hyphen sign. Others are used with double hyphen signs. Let's take some examples. Execute the following commands.
$ls $ls -l $ls --inode
By default, the ls command lists the contents of the current directory. In the first command, we did not use any option. So, it displayed all contents of the current directory. In the second command, we used the -l option. It is an example of a single hyphen sign option. When we use this option with the ls command, the command displays contents with their properties in a list format. In the third command, we used the --inode option. It is an example of a double hyphen sign option. When we use this option with the ls command, the command displays the inode number with the contents.
Arguments
Arguments are the input of the command. Everything you put after the command is arguments (including options). Technically, all options are arguments. But all arguments are not options. Options only modify the behavior of the command. Arguments control the output of the command. They specify a target for the command. Arguments are also optional. If you will not specify them, the command will use default values.
Let's take some examples. Execute the following commands.
$ls $ls data $ls -l data
The first command displays the contents of the current directory. This command does not use any option or argument.
The second command uses one argument. We specified the data directory's name as an argument. If we specify the target directory, the ls command displays the content of the specified directory.
The third command uses one argument and one option. The option instructs the command to display the output in the list format with detailed information. The argument instructs the command to display the content of the specified directory instead of the current directory.
this way, we can use options and arguments to modify the default behavior and output of the command.