Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit b8b869e

Browse files
committed
[Linux] Add common command structure
1 parent 81ccbbe commit b8b869e

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

src/linux/commands.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
*******************************************************************************
2+
Base Commands
3+
*******************************************************************************
4+
5+
A computer's operation, no matter which operating system it is running, can be
6+
loosely described in three steps:
7+
8+
#. The computer waits for user input
9+
#. The user selects a command and enters it via keyboard or mouse
10+
#. The computer executes the command
11+
12+
In a Linux system, the shell displays a "prompt", meaning that commands can be
13+
entered. This prompt usually consists of a user and host (computer) name, the
14+
current directory, and a final character:
15+
16+
::
17+
18+
user@host: /home/user >
19+
20+
Command structure
21+
=================
22+
23+
A command is essentially a sequence of characters which is ends with a press
24+
of the **enter** key and is subsequently evaluated by the shell. Many commands
25+
are vaguely inspired by the English language and form part of a dedicated
26+
"command language". Commands in this language must follow certain rules,
27+
a "syntax", for the shell to be able to interpret them.
28+
29+
To interpret a command line, the shell first tries to divide the line into
30+
words. Just like in real life, words are separated by spaces. The first word
31+
on a line is usually the actual command. All other words on the line are
32+
parameters that explain what is wanted in more detail.
33+
34+
Parameters starting with a dash (``-``) are called **options**.
35+
These are usually optional -- the details depend on the command in question.
36+
They are "switches" that allow certain aspects of the command to be switched
37+
on or off. If you want to pass several options to a command, they can be
38+
accumulated behind a single dash, i.e. the options sequence ``-a -l -F``
39+
corresponds to ``-alF``. Many programs have more options that can be
40+
conveniently mapped to single characters or support *long options* for
41+
readability (frequently in addition to equivalent single-character options).
42+
Long options most often start with two dashes and cannot be accumulated:
43+
``--foo --bar --foobar``.
44+
45+
Parameters with no leading dash are called **arguments**. These are often the
46+
names of files that the command should process.
47+
48+
The general command structure can be displayed as follows:
49+
50+
:command: what to do?
51+
:options: how to do it?
52+
:arguments: what to do it with?
53+
54+
Internal and external commands
55+
------------------------------
56+
57+
In shells, there are essentially two kinds of commands:
58+
59+
- **Internal commands**
60+
61+
These commands are made available by the shell itself.
62+
The Bourne-again shell contains approximately 30 such commands,
63+
which can be executed very quickly. Some commands (such as ``exit`` or
64+
``cd``) alter the state of the shell itself and cannot be provided
65+
externally.
66+
67+
- **External commands**
68+
69+
The shell does not execute these commands by itself but launches executable
70+
files, which within the file system are found in directories like */bin* or
71+
*/usr/bin*. As a user, you can provide your own programs, which the shell
72+
will execute like other external commands.

src/linux/index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@ their administration tools, extra services, and price.
128128
:name: linux
129129
:caption: Contents
130130

131-
utils
131+
commands
132132
filesys
133133
users

src/linux/utils.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)