RHSA1 Day4new
RHSA1 Day4new
● - Shell
● - Command
● - An application
●
3 Red Hat
Processes
●For everything that happens on a Linux server, a process is started.
●System starts processes called daemons which are processes that
run in the background and provide services.
●Every processes has a PID.
●When a process creates another, the first is the parent of the new
process. The new process is called the child process.
4 Red Hat
Processes
●Types of process:
●- Shell jobs.
●- Daemons.
5 Red Hat
Viewing Processes
●ps (process status) command
●ps [options]
● ● Output ● Options
– PID. – -e: all system processes.
●
– TTY -> terminal identifier. – -f: full information.
– Execution time. – -u uid: display processes of that user.
– Command name. – a: all processes attached to a terminal.
– x:all other processes.
6 Red Hat
Shell jobs
●Shell jobs are commands started from the command line. They associated
with the shell that was current when the process was started.
●When a user types a command, a shell job is started.
●By default, any executed command is started as foreground job.
●Ifyou know that a job will take a long time to complete, you can start it in with
an & behind it.
●This immediately starts the job in the background to make room for other
tasks to be started from the command line.
7 Red Hat
Shell jobs
●A signal is a message sent to a process to perform a certain action.
●Tosend signals to processe or process group , you can use kill
command, killall command or pkill command.
●kill -[signal] PID kill 12047
●pkill -[signal] process_name kill -9 mail
●killall process_name killall vim
●
8 Red Hat
Shell jobs
●Signalsare identified by a signal number and a signal name, and has
an associated action.
●– SIGTERM → 15 – SIGKILL → 9
●If no signal is specified, the TERM signal is sent.
●For complete overview of all the available signals, you can use man 7
signal.
●
9 Red Hat
Shell jobs
Examples
●sleep 3600&
●[1] 3302
●jobs
●[1]+ Running sleep 3600 &
●fg 1
●sleep 3600
●ctrl+z [1]+ Stopped sleep 3600
●jobs
●[1]+ Stopped sleep 3600
●bg %1
●[1]+ sleep 3600 &
10 Red Hat
Shell jobs
Examples
●jobs
11 Red Hat
Processes
●Everyprocess has a parent process, and as long as it lives, the parent
process is responsible for the child processes it has created.
●In older versions of Linux, killing a parent process would kill all of its
child processes.
●InRHEL 8, if you kill a parent process, all of its child processes
become children of the systemd process.
12 Red Hat
Processes Priority
●When Linux processes are started, they are started with a specific
priority.
●Bydefault, all regular proceeses are equal and are started with the
same priority, which is the priority number20.
●Every process which is ready to run has a scheduling priority.
●The Linux process divides CPU time into time slices, in which each
process will get a turn to run, higher priority processes first.
●User can affect the priority by setting the niceness value for a
process.
● 13 Red Hat
Adjusting Priority
●Niceness values range from -20 to +19, which indicates how much of a
bonus or penalty to assign to the priority of the process.
●To change the default priority that was assigned to the process when
it was started.
●Use nice if you want to start a process with an adjusted priority.
●nice [-n adjustment] command
●nice -n 5 dd if=/dev/zero of=/dev/null &
●
● 14 Red Hat
Adjusting Priority
●Use renice to change the priority for a currently active process, or you
can use the r command from the top utility to change the priority of a
currently running process.
●renice priority [[-p] pid ...] [[-g] group ...] [[-u] user ...]
●ps | aux
●renice -n 10 -p 1234
●The default niceness of a process is set to 0 (which results in the
priority value of 20.
●
●
15 Red Hat
Adjusting Priority
●By applying a negative niceness, you increase the priority.
●Use a positive nicenessto decrease the priority.
●Do not set process priority to -20, it risks blocking other processes
from getting served.
●The regular users can only decrease the priority of a running process.
●You must be root to give processes increased priority.
●
16 Red Hat
Viewing Processes
●Use top to display Linux processes.
●The top program provides a dynamic real-time view of a running
system.
●Itcan display system summary information as well as a list of
processes or threads currently being managed by the Linux kernel.
●
17 Red Hat
Searching For A Process
●To search for a process, you can use pgrep command.
●pgrep option(s) pattern.
●Options
18 Red Hat
Standard Input And Output
●Standard input:
●● Refers to the data source from which data is input to a command.
●● Typically the keyboard.
●Standard output:
●● Refer to data destination to which data from the command is written.
●● Typically the screen.
●Standard error:
●● Refer to the output destination for the errors and messages generated by the
● command.
●● Typically the screen also.
19 Red Hat
Standard Input And Output
●InI/O redirection, files can be used to replace the default standard
input, standard output and standard error.
●You can also redirect to device files.
●If you want to discard a command’s output, you can redirect to
●/dev/null.
20 Red Hat
Redirection
●Standard input:
●● command < fname
●Standard output:
●● command > fname
●● command >> fname
●Standard error:
●●command 2> fname
●●command 2> /dev/null
21 Red Hat
Redirection
●Examples:
22 Red Hat
Pipe Line
●A pipe (|) is used to send the output of one command as the input to
another.
●Command 1 | Command 2.
●Examples:
23 Red Hat
The tee Command
●The tee command reads from the standard input and writes to the
standard output and a file.
●Examples:
24 Red Hat
String Processing
●Usethe wc and the diff commands to gather word file statistics and
compare two files.
●Search strings for patterns using the grep command.
●Move and delete data using cut and paste commands.
●Organize data using the sort, and paste command.
25 Red Hat
The wc command
●The wc command displays the number of characters, words, and lines
in a specified file.
●The syntax for the wc command is:
● wc [option] [filename]
●The wc command is often used when differentiating between two
versions of a file.
26 Red Hat
The wc command
● Option Meanings
● -c Count the number of characters only.
●
●
Example:
●
wc story.txt
●
39 237 1901 story.txt
27 Red Hat
The diff command
●The diff command is also used to compare the contents of two files for
differences. If you upgrade a utility and want to see how the new
configuration files differ from the old, use the diff command.
●diff /etc/named.conf.rpm.new /etc/named.conf
●will give the output as:
●20c20
●<
Option Description
-i Not case sensitive.
30 Red Hat
The cut command
●cutcommand cuts fields or columns of text from standard input or the named file
and displays the result to standard.
●The syntax for the cut command is:
● cut option[s] [filename]
●Options
Thank You
sbahader@gmail.com
33 Red Hat