Welcome back friends here in this part we are going to learn about our HCl or linings processes. So, what are processes, you might have seen Windows Task Manager, if you're using Windows, where you can see where various background and foreground tasks that are running on the systems. So, task could be also called as process actually processes are different from task because a certain task may need different process to be executed. So, in Linux, it is very vital to understand what processes are and what are different processes and how we can organize them or control them to perform a better operations and provide different solutions. So let's start. A process is a set of instruction that is loaded into memory.
The numeric process or P ID, the process ID is used for identification of each process UID g ID and SC Linux context determines file system access to different processes. One thing to observe is that in Linux system, there is a process that is parent of all processes, which is called as in it, I am it the init process is starts at the beginning of the OS and executes till the end. If you you also pass various commands were number two in it like in ID zero, which is the init process. And so the system was shut down. If you write in it, the sixth then the system reboots or restarts. So, there are different process you can view information regarding various process with a PS command the PS and provide the number it will show the processes you can also use various arguments.
It shows the process by the current user on the current terminal by default, there are various options minus he would show you all list of all processes, you will allow users to show all process by the user based on each user capital F will print extra information capital H will indent it child processes Oh a small o will show the properties with a properties it could print custom informations and you can use ps3 command for process tree it is a reverse tree. We are the different first process is in it and all the processes are derived from it. To do a practical of these things, so don't worry. You can find a process by using the command PS provide the options and you can use a pipe operator and perform with other commands. You can also use the predefined patterns with P grip GRP. As here, you can also track program names, which are stored in s bin B ID or directory.
There are various signals that could be sent to kill the process or to terminate or perform various operations I've already told you, you need to zero are in it fix. The six and zero are the signals which is numbered and could be used to perform various operations signals are sent directly to process no user interface is required. Programs associate actions with each signal signals are specified by name or number when sent. For example signal 15 the term it terminates cleanly, signal nine will kill the Terminator process image with signal one reread configuration of file system and manual seven was signal show complete list. There are various types of process, one of them is called down payment or background process. When you see the after any name of the process, it is actually demand for example, in it now, so not in it is not a thing like that we could be using anything there is demand right there the hidden process could also be controlled or foreground process are also be controlled.
The scheduling is another thing we can schedule different processes like execution that this process will execute first this will execute next and this will after the after time in case when different processors arrive at the processor or CPU at the same time. So, CPU could not decide to which processor which processor it needs to execute if we do not provide any scheduling or priority So, the priority is affected by the nice value. Linux has provided you the nice value. Nice value with allow you to upgrade our Prioritize a process or D prioritize a process it ranges from a value of minus 20 to 19. But default value of all the processes zero, you can lower the nice process means lower nice value means higher CPU priority the process which have the lower nice value, yes the CPU you can view the priority with with PS minus o command and a nice you can change the nice value by writing the command nice is base minus and provide the number, the nice number and the command and you can also change by using the re nice value.
However, only root access root user may decrease nice values. You can only only increase and you Are any non root users but only root can decrease or prioritize process. There is our interactive process management tools out there. The top is used as a CSI mode and genome System Monitor is used energy wave mode. It has various capabilities, it could display real time process information, it allows you sorting, killing and renaming the processes for your functionalities, then we have job controls for the process. If you have if you have read or learned about operating systems and various process you might be familiar with your controls.
When different process allows to the system CPU at the same time, they are assigned various jobs to be performed. It may occur that a certain process is executing and it is a stop in between To allow other persons to execute in parallel, actually there is nothing like parallel system only one CPU is allowed sorry in single core processors there is no concept of parallelism, but actually multitasking is done. That is because, the processes are allowed and D allowed to assign certain time limit to execute. That is also called a job control processes could also be called as jobs in OSS terminologies. It we can run process in the background, append or ampersand to the command line. You can temporarily halt a running program or stop.
You can use Ctrl Z to send signal 19 that is a stop. You can manage background or suspend job, manage background or sub suspended jobs. You can list job numbers and names with jobs GPS command. You can resume the bag in the background, the process in the background by using the background command. You simply write BG and provide the job number. job number is the process ID.
You can resume in the foreground using the F g command, you can send a signal like kill signal with K double L, and the signal number and the job number. Similarly, you could use the exit status. The exit status is used to process or report success or failure with an exit you can do with exit status. Zero is used for success. One to 255 values are used for failure. You can check whether the process has completed successfully or it has result in a failure.
Dollar question mark is to the exit status of most recent combined exit is pace the number which you assigned for success or failure 10 minutes to set a status to number. This is an example, how we can do so. There are conditional execution execution operators, like and or, which can be used to run conditionally to run various operations like if else conditions. Double ampersand symbols represent and then, and double pipe symbol represent conditional or as you can test various commands the test command is used to evaluate Boolean statements with conditionals Return zero for true return one is used for false. If the execution is fine, then return zero means true. If it is not fine return one and C two for false.
A test command is used with variables and different arguments where ampersand, double ampersand symbol for n and double pipe symbol for all is can be used. You can test files with three different arguments minus a minus t minus x. minus F is used to test to see if a file exists and is a regular file minus d to test to see if a file exists and is a directory minus x to test. If a file exists and is an executable, you can test a file. Learn more about that file. Then there concise scripting, we have been learning shell scripting in earlier parts. Here I introduce you to the if statement for shell scripting, you might be familiar with certain types of programming languages.
The syntax could be different for you if you have been using Java or C based languages. Here the if else statement is written as if Elif, that is elsif. for short. And as and after that, you have to again write f i is a reverse of if, because I hear we don't use any brackets and kind of curly brackets or any type of margins that we use in Python. Here, the if is a fence letter could be created. The if statement is checked, if it is correct, then the execution is processed within the if statement like the first line of Rico station one is up.
If the condition fails the Elif condition elsif condition or Elif condition is checked. It also fails it moves to as whatever condition is satisfied that one is executed all the rest are not executed. You can write your own shell script, run a process check, manipulate process, use the signals and do a wide range of operations on job scheduling process and various things. Using process. manipulating process and jobs is actually an administrator job. It is a very good thing.
So if you want to be a server administrator on average here, you must be familiar with jobs, process and certain tasks. Keep learning keep moving as we will learning more in the coming videos.