Page 34 - Raspberry Pi as a Foundation for Boosting Computer and Technology Literacy
P. 34
3 Fundamentals of the Linux system and terminal usage
Figure 3.5 Example of a shell command with a flag and an argument
3.2 Basics of shell commands 3.2
The shell commands adhere to the following format and accept addi-
tional flags and arguments:
command [flags] [arguments]
Flags (or attributes) are additional parameters used to enable or
disable certain functionalities of a command, thereby modifying its
behaviour. They are typically preceded by a hyphen ‘-’ (e.g. -e) or two
hyphens ‘--’ (e.g. --version). When combined with the arguments,
which are the specific data that the command operates on, they ulti-
mately control command execution.
For demonstration purposes, we will resort to a useful ls command
that displays the files and folders within a specified directory. Consider
the following ls command (Figure 3.5) with the -a flag to show hid-
den files and the tilde character ‘~’ as an argument. The tilde symbol is
understood by the shell as a path to the user’s home directory:
ls -a ~
To clear the terminal window from the command output, one can
use the clear command or the key combination ‘CTRL+L’.
Input and output streams
Processes on a Linux system interact with each other through input
and output streams. They receive data from standard input (stdin), out-
put data to standard output (stdout), and report errors via standard er-
ror (stderr) (Ward 2021, 14). The stdin of a process, initiated by a shell
command, can originate from various sources, such as a file or another
shell command. Similarly, a stdout can be generated by the Linux ker-
nel, a file, another shell command, etc.
In the previous example, the ls command received a path to a di-
rectory as its stdin and returned the list of the directory’s contents as
the stdout. In that case, the stdout was captured and displayed by the
terminal. However, this does not necessarily have to be the case, as the
34