Read LPI Linux Certification in a Nutshell Online
Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger
Tags: #Reference:Computers
Processes have:
A lifetime
A PID
A UID
A GID
A parent process
An environment
A current working directory
Generate a one-time snapshot of the current processes on
standard output.
Display a hierarchical list of processes in a tree
format.
Generate a continuous, formatted, real-time process
activity display on a terminal or in a terminal window.
Processes listen for
signals
sent by the kernel or users using the
kill
command:
kill
-sigspec
[pids
]
Sendsigspec
topids
.
The
killall
command is used to send
signals to processes by program name instead of PID.
Common
kill
signals are listed in
Table 10-6
.
Table 10-6. Common signals
Signal | Number | Meaning |
---|---|---|
HUP | 1 | Hangup, reread |
INT | 2 | Interrupt, stop |
KILL | 9 | Exit immediately. |
TERM | 15 | Terminate nicely. |
TSTP | 18 | Stop executing. |
Shells can run processes in the
background
,
where they execute on their own, or in the
foreground
, attached to a terminal. Each process
handled in this way is known as a
job
. Jobs are
manipulated using job control commands:
jobspec
]Placejobspec
in the background
as if it had been started with&
.
jobspec
]Placejobspec
in the
foreground, making it the current job.
jobspecs
]Listjobspecs
on standard
output.
command
] &Executecommand
, detach it from
the terminal, and allow it to continue running after the user
logs out.
A process’s
execution priority
is managed by the kernel.
You can bias the execution priority by specifying a
nice number
in the range of –20 to +19
(default is 0).
Positive nice numbers reduce priority; negative nice numbers
increase priority and are reserved for the superuser.
-
adjustment
[command
]Apply nice numberadjustment
to
the process created to runcommand
.
[+|-]
nicenumber
targets
Alter thenicenumber
, and thus
the scheduling priority, of one or more runningtarget
processes.
Regular expressions
are used to
match text. The term is used to describe the loosely defined
text-matching language as well as the patterns themselves. A
regular expression is often called a
regex
or
a
regexp
.
Regular expressions are made up of
metacharacters
(with special
meaning) and
literals
(everything that is not
a metacharacter).
The backslash character (\
) turns off (escapes) the special
meaning of the character that follows, turning metacharacters into
literals. For nonmetacharacters, it often turns on some special
meaning.
The operators in
Table 10-7
match line
position.
Table 10-7. Regular expression position anchors
Regular | Description |
---|---|
^ | Match the beginning of a |
$ | Match the end of a |
\< \> | Match word boundaries. Word |
The operators in
Table 10-8
match
text.
Table 10-8. Regular expression character sets
Regular expression | Description |
---|---|
[ [ | Match any single character from |
[^ [^ | Match any single character not among |
. | Match any single character except a |
The operators in
Table 10-9
modify the way other
operators are interpreted.
Table 10-9. Regular expression modifiers
Basic regular | Extended | Description |
---|---|---|
* | * | Match zero or more of the character |
\? | ? | Match zero or one instance of the |
\+ | + | Match one or more instances of the |
\{ | { | Match a range of occurrences of the |
\| | | | Match the character or expression to |
\( | ( | Matches |
Many commands support the regular expression syntax, but the
most commonly used is the command
grep
, which
is designed to display lines from a file or files matching a given
regular expression.
There are multiple ways to call
grep
to
change its behavior:
Treat the pattern as a basic regular
expression.
Treat the pattern as an extended regular expression.
Same as
grep –E
.
Treat the pattern as a list of fixed strings, any of
which may be matched. Same as
grep
–F
.
Start
vi
with
vifile1
[file2
[...]]
. See
Table 10-10
.
Table 10-10. Basic vi editing commands
Command | Description |
---|---|
Esc | Exit insert mode and put the |
| Move left one |
| Move down one |
| Move up one line. |
| Move right one |
H | Move to the top of the |
L | Move to the bottom of the |
G | Move to the end of the |
W | Move forward one |
B | Move backward one |
| Move to the beginning of the |
^ | Move to the first nonwhitespace |
$ | Move to the end of the current |
Ctrl-B | Move up (back) one |
Ctrl-F | Move down (forward) one |
i | Insert at the current cursor |
I | Insert at the beginning of the |
a | Append after the current cursor |
A | Append to the end of the current |
o | Start a new line after the |
O | Start a new line before the |
r | Replace the character at the |
R | Start replacing (overwriting) at |
x | Delete the character at the |
X | Delete the character immediately |
s | Delete the character at the |
S | Delete the contents of the |
d | Given a movement command |
dd | Cut the entire current |
D | Cut from the current cursor |
c | Given a movement command |
cc | Cut the entire current line and |
C | Cut from the current cursor |
y | Given a movement command |
| Copy the entire current |
p | Paste after the current cursor |
P | Paste before the current cursor |
. | Repeat the last |
u | Undo the last |
/ | Search forward for |
? | Search backward for |
n | Find the next |
N | Find the previous match. (In |
:n | Next file; when multiple files |
:e | Load |
:r | Insert the contents of |
:q | Quit without saving changes. |
:w | Write the current buffer to |
:wq | Write the file contents and |
:x | Write the file contents (if |
ZZ | Write the file contents (if |
:! | Execute |