Linux/C2/Working-with-Linux-Process/English-timed

From Script | Spoken-Tutorial
Revision as of 15:07, 28 December 2012 by Minal (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
0:00 Welcome to this spoken tutorial on working with Linux Processes.
0:05 I am using Ubuntu 10.04.
0:09 We assume that you know how to get started with the Linux operating system and have some basic idea about commands.
0:16 If you are interested, it is available through another spoken tutorial, on the following website http://spoken-tutorial.org/ http://spoken-tutorial.org.
0:28 Also note that Linux is case sensitive. All the commands used in this tutorial are in lower case unless otherwise mentioned.
0:38 To understand what a process is let me give you an brief explanation.
0:42 Anything that is running in Linux is a process.
0:46 The shell that is running and taking our commands is a process.
0:51 The commands that we type on the terminal are processes when they are running.
0:56 The video in which you are seeing this tutorial is a process.
1:00 The browser running in which you have opened the spoken tutorial website is a process.
1:05 Shell scripts that are running are processes and so on.
1:11 A process can be defined as a program which is being executed i.e. which is running.
1:17 Processes are much like us. They are born, they die. They have parent and children.
1:28 Let us first learn about the shell process.
1:31 The shell process is started by the Linux kernel as soon as we login to the system.
1:36 At this point it would suffice to know that the Linux kernel is the core of the Linux operating system.
1:43 It consists of the most essential components that makes Linux run. The shell creates or gives birth to all the other user command processes.
1:53 Let us open a terminal.
1:57 We can see the command prompt on the terminal in the form of a dollar sign.
2:03 This is the job of the shell process.
2:07 Now let us type any command, say “date” and press enter.
2:13 As soon as we do this the shell process will create a process called date.
2:18 Now since the shell process has given birth to the date process, we can say that the shell process is the parent of the date process and the date process is the child of the shell process.
2:30 Once date process has shown the system date and time, it will die.
2:40 A shell can also give birth to another shell process. Giving birth to a process or creating a process is also called spawning a process.
2:50 To spawn another shell process, simply go to the terminal and type “sh” and press enter.
3:00 We would see a new prompt appearing in the terminal. Now our original shell , let us call it shell 1, has given birth to a child shell or sub shell,let us call it shell 2.
3:13 Now you may run a command in the new command prompt as well. Let us run ls command in this new command prompt.
3:20 Now at the command prompt type “ls” and press enter.We can see a list of files and directories.
3:32 Now a new process named ls is created.
3:35 Here, shell 2 is the parent of ls, while shell 1 is the grandparent of ls. ls is the child of shell 2, while shell 2 itself is the child of shell1
3:56 To kill shell 2 simply type at the new prompt “exit” and press enter.
4:04 This will kill shell 2 and we will get back our original command prompt.
4:12 Continuing our analogy between us and processes ,we know that each of us have some attributes that identify us. Those attributes can be our name, parents' name , date of birth, PAN card no. etc.
4:26 Similarly processes also have attributes like PID(Process ID), PPID(Parent Process ID), Start time, etc.
4:38 Most of these attributes are maintained by the kernel in a process table.
4:43 Each process is uniquely identified by a unique integer called the PID. PID is allotted by the kernel when the process is born.
4:51 The PID of the parent process that spawned a new process say P1 is called the PPID of P1 process.
5:00 To see the PID of the current shell at the prompt type“echo space dollar dollar” and press enter
5:11 A number would be shown . This is the PID of the current shell.
5:23 The one command that we would use a lot while talking about processes is the ps command.
5:29 ps or process status is a command which displays the processes running in the system.
5:34 Let us see what happens if we run this command without any options.
5:40 Now at the command prompt type “ps” and press enter.
5:47 This way we would normally see the list of all the processes owned by the user running the program.
5:54 You can see the name of the process under CMD heading.
5:58 Other than this you can a see the PID, TTY or the console at which the process is running ,the TIME
6:06 that is the total processor time that has been used since the process started
6:12 On my machine it displays two processes.
6:16 One is bash, the shell process we are using. The other is the ps process itself.
6:25 The other important thing to note here is that the PID of the shell process is same as that shown by the echo space dollar dollar command.
6:35 If we spawn a subshell , let us see what happens. At the terminal type “sh” and press enter.
6:42 Now in the new prompt that appears on the new line, type “ps” and press enter.
6:51 Now we can see 3 processes in the list . The process sh has been added.
6:57 Here again notice that the PID of the bash process is same as that before.
7:05 ps comes with many options as we would see next. First option that we would see displays more attributes for the processes listed.
7:13 Now type at the prompt “ps space minus f” and press enter.This again will list three processes as in the previous case.
7:28 Bash, sh and ps -f.
7:31 The only difference is now more attributes are listed.
7:36 UID gives the user name of the user who has started the process. Also it shows the PPID that is the PID of the parent process that created the process.
7:47 For example see that bash process is the parent of sh process , so the PID of bash is same as the PPID of sh process.
8:00 Similarly since sh process is the parent of ps process, the PID of sh process is the same as the PPID of the ps -f process.
8:17 C stands for processor utilization. Currently, this is the integer value of the percent usage of the processor over the lifetime of the process.
8:26 It will be displayed as 0 in this case as the usage is negligible.
8:32 The STIME field gives the time at which the process started, the rest we have already seen while running ps.
8:42 Processes are of two types : First one is User processes. Those are started by the users.
8:49 For example 'ps' or for that reason most commands that we run on the terminal.
8:54 Second one is system processes. Those processes are started by the system often during system startup or user login.
9:05 Example of system process can be bash.
9:09 Sometimes we may want to see all the processes - both system processes as well as user processes.
9:17 Then we use the minus e or the minus capital A option.
9:23 Go to the terminal and type at the prompt “ps space minus e” and press enter.
9:32 We can see a large list of processes.
9:35 To get a multipage display just type at the prompt
9:40 “ps space minus e space vertical bar space more” and press enter.
9:52 As we have seen before more will cause only as many processes to be listed as can fit in one window.
9:58 As we press enter we scroll through the list of processes.
10:03 The first process in this list is interesting. It is called the init process.
10:09 It is the process from which almost all other processes are spawned.
10:12 It has a PID of 1.
10:16 To come back to the prompt press q
10:24 So, in this tutorial, we have learned about process, shell process, spawning of process, process attributes and different types of processes.
10:37 We also learned the use of ps command. This brings me to the end of this tutorial.
10:45 Spoken Tutorials is a part of the Talk to a Teacher project, supported by the National Mission on Education through ICT, MHRD, Government of India.
10:55 More information on the same is available at the following link

http://spoken-tutorial.org/NMEICT-Intro.

11:07 This script has been contributed by ----------------------(name of the translator) and this is -----------------------(name of the recorder) from --------------------------(name of the place)signing off. Thanks for joining.

Contributors and Content Editors

Minal, PoojaMoolya, Pratik kamble, Sandhya.np14