Beginning With Shell Scripting: 1) Kernel 2) Shell 3) Process 4) Redirectors, Pipes, Filters Etc
Beginning With Shell Scripting: 1) Kernel 2) Shell 3) Process 4) Redirectors, Pipes, Filters Etc
$ ls
$ date BASH 00100110 Linux Kernel
$ time 11001001
It is an environment provided for user interaction. Shell is a command
language interpreter that executes commands read from the standard
input device (keyboard) or from a file. Linux may use one of the
following most popular shells (In MS-DOS, Shell name is
COMMAND.COM which is also used for same purpose, but it's not as
powerful as our Linux Shells are!)
Any of the above shell reads command from user (via Keyboard or
Mouse) and tells Linux O/s what users want. If we are giving commands
from keyboard it is called command line interface ( Usually in-front of $
prompt, This prompt is depend upon your shell and Environment that
you set or by your System Administrator, therefore you may get
different prompt ).
NOTE: To find your shell type following command
$ echo $SHELL
31-03-19
What is Processes?
Process is any kind of program or task carried out by your PC. For e.g. $
ls -lR, is command or a request to list files in a directory and all
subdirectory in your current directory. It is a process. A process is
program (command given by user) to perform some Job. In Linux when
you start process, it gives a number (called PID or process-id), PID starts
from 0 to 65535.
Linux is multi-user, multitasking o/s. It means you can run more than
two process simultaneously if you wish. For e.g.. To find how many files
do you have on your system you may give command like
$ ls / -R | wc -l
This command will take lot of time to search all files on your system. So
you can run such command in Background or simultaneously by giving
command like
$ ls / -R | wc -l &
The ampersand (&) at the end of command tells shells start command
(ls / -R | wc-l) and run it in background takes next command
immediately. An instance of running command is called process and the
number printed by shell is called process-id (PID), this PID can be used
to refer specific running process.
Linux commands related to process
Process Command Example
To see currently ps $ ps
running process
To stop any process Kill {PID} $ kill 1014
ie. To kill a process
To get info about all ps –ag $ps –ag
running processes
to stop all processing kill 0 $ kill 0
except your shell
for background Linux-command & $ ls / -R |wc –I &
processing
Filter
If a Linux command accepts its input from the standard input and
produces its output on standard output is known as a filter. A filter
performs some kind of process on the input and gives output. For e.g.
Suppose we have file called 'hotel.txt' with 100 lines data, And from
'hotel.txt' we would like to print contains from line number 20 to line
number 30 and store this result to file called 'hlist' then give command
$ tail +20 < hotel.txt | head -n30 >hlist
Here head is filter which takes its input from tail command (tail
command start selecting from line number 20 of given file i.e. hotel.txt)
and passes this lines to input to head, whose output is redirected to
'hlist' file.