Shell, Terminal, Filesystem
-
A shell is a command interpreter
-
some are internal commands
-
most come from the Operating System (OS)
-
some are created by the user!
-
-
The shell is the interface between us, users, and the OS when it comes to using commands
-
So the name Command Line Interface (CLI)
-
Shell, Terminal, Filesystem
-
The shell interprets commands only
-
The job of the terminal is to get keystrokes (sometimes mouse events) from the user and display things
-
Nowadays, we don’t use terminals anymore, only terminal emulators
-
However, we commonly say terminal to designate both the terminal emulator and the shell!
Shell, Terminal, Filesystem
-
Everything within Linux is considered a file
-
Using the shell properly can’t be achieved without understanding the notion of Filesystem
-
Some slides about that later!
Command Prompt
-
Launching a terminal means creating a new shell process
-
Every shell has its own command prompt to invite us to type in commands (
luisgustavo.nardin@fayol-nardin:~$on the screenshot below)

Anatomy of a command
-
is a single program we want to run
-
can also be seen as a command pipeline
-
arguments (the raw materials it works on)
-
options (that alter its behaviour)
-
some options have arguments themselves…
-
Anatomy of a command: an example
-
$>: the command prompt (is not part of the command) -
gcc: the command (possibly preceded by an absolute or relative path) -
-W -Wall -ansi -pendantic -o prog: options-
progan argument for the option-o
-
-
prog.c: an argument for the command
-
--versionis a long option
Anatomy of a command: guess 1/4
$> /usr/bin/ls
Anatomy of a command: guess 1/4
$> /usr/bin/ls
Anatomy of a command: guess 2/4
$> zip -r -9 -v homedir.zip ${HOME}
Anatomy of a command: guess 2/4
$> zip -r -9 -v homedir.zip ${HOME}
Anatomy of a command: guess 2/4
$> zip -r9v homedir.zip ${HOME}
Anatomy of a command: guess 3/4
$> LANG=C man -k who
Anatomy of a command: guess 3/4
$> LANG=C man -k who
Anatomy of a command: guess 4/4
$> tar zcvf homedir.tar.gz ${HOME}
Anatomy of a command: guess 4/4
$> tar zcvf homedir.tar.gz ${HOME}
Anatomy of a command: guess 4/4
$> tar -z -c -v -f homedir.tar.gz ${HOME}
Anatomy of a command: guess 4/4
$> tar --create --file homedir.tar.gz --verbose --gzip ${HOME}
Follow the PATH
-
Commands are present in various directories
-
To find a command, the Shell makes no guess, he only searches some directories
⇒ Those listed in thePATHvariable -
The Path is defined on a per user basis
PATH variable$> echo ${PATH}
/home/luisgustavo.nardin/.local/bin:/home/luisgustavo.nardin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:.
Windows too has the notion of path. It is called … path and can be set using the GUI or the command line (cmd.exe or PowerShell)
|
References
-
"Unix Text Processing", Dale Dougherty and Tim O’Reilly, Hayden Books, 1987
https://www.oreilly.com/openbook/utp/ -
Christophe Blaess cheat sheets[FR]
https://www.blaess.fr/christophe/developpements/aides-memoires/-
Unix commands[FR]
https://www.blaess.fr/christophe/memo_commandes_unix.html -
Shell programming[FR]
https://www.blaess.fr/christophe/memo_programmation_shell.html
-
-
Rich’s sh (POSIX shell) tricks
https://www.etalabs.net/sh_tricks.html -
Bash Reference Manual
https://www.gnu.org/software/bash/manual/bashref.html
-
Advanced Bash-Scripting Guide
http://tldp.org/LDP/abs/html/ -
"Mastering Regular Expressions, 3rd Edition — Understand Your Data and Be More Productive", Jeffrey Friedl
https://www.oreilly.com/library/view/mastering-regular-expressions/0596528124/ -
"GAWK: Effective AWK Programming", Edition 4.1
http://www.gnu.org/software/gawk/manual -
Manual pages‡ :
bash(1),grep(1),regex(7),gawk(1)
‡ : read thoses pages on your own operating system, not on the Internet!