Mastering Linux Processes: ps, top, kill
See what the attributes of processes (programs) in Linux are
It is important that you understand that each program is at least one process and that each process has some attributes, such as:
- Process ID (PID) or process identification: Each process has a unique identification number. The first init process will always have PID 1 and for the remaining processes this number is incremented as new processes are executed;
- User ID and Group ID: Processes need to be executed with the privileges of a user account and the group associated with them. This is important because this way the system can determine and manage access to resources;
- Parent Process: In Linux no process is executed independently from others. All processes in the system, with the exception of init, have a parent process, which is responsible for its execution. The ParentID attribute records the PID of the parent process. If the parent process finishes its execution before the child process, the child process is "adopted" by init, gaining Parent ID equal to 1;
- Environment variables: Each process inherits from the parent process some environment variables that simply store some values that may or may not be important for the running process. It is possible that during its execution a process may alter, increment or delete an environment variable. A child process can inherit variables from a parent process. But a parent process cannot access variables created or modified by its children.
- Working directory: Processes are also associated with a working directory, where they can read from and write to the disk;
- Timers: The Kernel keeps records of the time when processes are created as well as the CPU time they consume during their execution.
In a multiprogrammed environment with only one processor, each process is executed a little at a time, in an interleaved manner.
The operating system allocates the CPU a little to each process. A process after receiving control of the processor will only lose it when an interruption occurs or when it requires some service from the operating system.
These interruptions are transparent to processes, as they only temporarily interrupt their execution, which will then continue to be executed as if nothing had happened.
When requesting a service from the operating system, the process is blocked until the service requested from the operating system is satisfied.
Learn much more about Linux in our online course. You can enroll here with a 7-day free trial. If you already have an account, you can access here.
Like it? Share :-)
That was just one piece. The course teaches the whole path — from your first command to exam day.