A process is an instance of a program running in Linux and is the basic unit for managing transactions; a process has its own independent processing environment and system resources. The status of a process changes, including process creation, scheduling, and death.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
A process is an instance of a program running in Linux.
In the Linux system, the operating system completes tasks one by one through processes, and the process is the basic unit for managing transactions. The process has its own independent processing environment (such as: which environment variables are currently needed, where is the directory where the program is running, which user is currently running the program, etc.) and system resources (such as: processor CPU occupancy, memory, I /O devices, data, programs).
When you execute a program in a Linux system, the system will create a specific environment for the program. This environment contains everything the system needs to run the program.
Every time you execute a command in Linux, it creates, or starts, a new process. For example, when you try to run the command "ls -l" to list the contents of a directory, you start a process. If there are two terminal windows displayed on the screen, then you may have run the same terminal program twice, and there will be two terminal processes.
Each terminal window may be running a Shell, and each running Shell is a process. When you call a command from the Shell, the corresponding program will be executed in a new process. When the program's process execution is completed, the Shell's process will resume running.
The operating system tracks processes through a numerical code called a PID or process ID. Every process in the system has a unique PID.
Now we use an example to understand the process in Linux. We execute the following command on the Shell command line:
$ sleep 10 & [1] 3324
Because the program will wait for 10 seconds, we quickly search for any process named sleep on the current Shell:
$ ps -ef | grep sleep mozhiyan 3324 5712 cons1 17:11:46 /usr/bin/sleep
We see A process named /usr/bin/sleep
is running on the system (its PID is the same as the PID we got in the previous command).
Now, we try to run the above sleep command from 3 different terminal windows in parallel. The output of the above command will be similar to the following:
$ ps -ef | grep sleep mozhiyan 896 5712 cons1 17:16:51 /usr/bin/sleep mozhiyan 5924 5712 cons1 17:16:52 /usr/bin/sleep mozhiyan 2424 5712 cons1 17:16:50 /usr/bin/sleep
We see each of the sleep program Instances are created as a separate process.
Each Linux process has another ID number, the ID of the parent process (ppid). Every user process in the system has a parent process.
The command "ps -f" will list the PID and PPID of the process. The output of this command is similar to the following:
$ ps -f UID PID PPID TTY STIME COMMAND mozhiyan 4124 228 cons0 21:37:09 /usr/bin/ps mozhiyan 228 1 cons0 21:32:23 /usr/bin/bash
The commands you run at the Shell command line prompt all use the current Shell process as the parent process. For example, if you enter the ls command at the Shell command line prompt, the Shell will execute the ls command. At this time, the Linux kernel will copy the Shell's memory page and then execute the ls command.
In Unix, each process is created using the fork and exec methods. However, this approach results in a loss of system resources.
In Linux, the fork method is implemented using copy-on-write memory pages, so it only causes the loss of time and memory required to copy the memory page table of the parent process, and will create a new page table for the child process. A unique task structure.
The copy-on-write mode avoids creating unnecessary structure copies when creating a new process. For example, if the user outputs the ls command at the Shell command line prompt, the Linux kernel will create a Shell child process, that is, the Shell process is the parent process, and the ls command process is the child process. The ls command process will point to this Shell uses the same memory page, and then the child process uses copy-on-write technology to execute the ls command.
State of the process
Each Linux process has its own life cycle, such as creation, execution, termination and cleanup. Each process also has its own status, which shows what is currently happening in the process. The status of a process changes, including process creation, scheduling, and death.
The process can have the following states:
D (uninterruptible sleep state) - the process is sleeping and cannot be resumed until an event occurs.
R (Running status) - The process is running.
S (Sleep state) - The process is not running, but is waiting for an event or signal.
T (stop state) - The process is stopped by a signal, such as the signal SIGINT or SIGSTOP.
Z (Zombie state) - Processes marked
are zombie processes and remain because their parent process properly destroyed them. If the parent process exits, these processes will be destroyed by the init process.
To view the status of the specified process, you can use the following command:
ps -C processName -o pid=,cmd,stat
For example:
$ ps -C sleep -o pid=,cmd,stat CMD STAT 9434 sleep 20 S
Related recommendations: "Linux Video Tutorial》
The above is the detailed content of What does process mean in linux?. For more information, please follow other related articles on the PHP Chinese website!

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor