Understanding Linux Processes and Shell Commands
Classified in Technology
Written on in
English with a size of 2.18 KB
Unit 2: Linux Process Management
What is a Process?
A process is defined as an entity that represents the basic unit of work to be implemented in the system.
Foreground and Background Processes
- Foreground Process: Every process, when started, runs in the foreground by default. It receives input from the keyboard and sends output to the screen.
- Background Process: It runs in the background without requiring keyboard input. Other processes can run in parallel because they do not have to wait for the background process to complete.
Different Types of Processes
Parent and Child Processes
The second and third columns of the ps -f command display the Process ID (PID) and Parent Process ID (PPID). For each user process, there is a parent process in the system, with most commands having the shell as their parent.
Zombie and Orphan Processes
After completing execution, a child process is terminated, and the SIGCHLD signal updates the parent process. If a parent process is killed before the child process terminates, the child becomes an orphan process, and the init process becomes its new parent. A process that has finished execution but remains in the process table is called a zombie process.
Daemon Processes
These are system-related background processes that often run with root permissions. They service requests from other processes and wait for tasks to perform (e.g., print daemon).
Internal vs. External Commands
Internal Commands
These commands are built directly into the shell. Execution is fast because the shell does not need to search the PATH variable or spawn a new process. Examples: source, cd, fg.
External Commands
These commands are not built into the shell. When executed, the shell searches for the command path within the PATH variable and spawns a new process. These are typically located in /bin or /usr/bin. Example: The cat command located at /usr/bin/cat.