What is a Process?
- A process in Linux is a running program or task. It's an instance of a program that is being executed by the Linux kernel.
- Each process has its own unique Process ID (PID), which is a numerical identifier that distinguishes it from other processes.
Process Characteristics:
- Processes have their own set of resources, including memory, CPU time, file descriptors, and more.
- Each process is isolated from other processes, meaning they can't directly access the memory or resources of another process.
Creation of Processes:
- Processes are typically created in Linux through the fork() system call. This call creates a new process that is a copy of the calling (parent) process.
- The exec() system call can be used to replace the program in the current process with a new one. This is commonly used for running different programs within the same process.
Process Hierarchy:
- Processes in Linux are organized into a hierarchical structure, with a parent-child relationship. Each process, except the initial process (usually PID 1), has a parent process.
- When a parent process spawns a new child process, the child inherits some attributes from the parent, such as environment variables and open file descriptors.
- Monitoring ProcessesThe ps command is used to list currently running processes in the terminal, along with their details such as PID, status, and resource usage.
- The top or htop commands provide a dynamic, real-time view of running processes and system resource usage.
- You can send signals to processes using commands like kill to terminate or interact with them.
Daemon Processes:
- Daemon processes are background processes that run without any user interaction, often providing system services. Examples include web servers, database servers, and printing services.
Process States:
- Processes can be in different states, such as running, sleeping, stopped, or zombie. These states indicate what the process is currently doing.
Process Management
- ps Command:
- ps lists running processes.
- ps aux shows detailed process information.
- ps aux | grep username filters processes for a specific user.
- cat /proc//status Command:
- Displays detailed info about a process with a specific PID.
- top Command:
- Real-time process monitor.
- top -u username shows processes for a specific user.
- top -u root focuses on root user processes.
- gnome-system-monitor:
- GUI-based system monitor for a graphical view of processes and system resources.
- kill Command:
- kill is used to stop a process by its PID.
- kill -9 sends a forceful SIGKILL signal to terminate a process.
- systemctl Command:
- sudo systemctl status service_name checks the status of a service.
- sudo systemctl start service_name starts a service.
- sudo systemctl stop service_name stops a service.
Network commands and configurations in Linux:
- Network Interface Commands:
- ifconfig, ip addr, and ip link display network interface information, including names and configurations.
- Routing Information:
- ip route shows routing information for the network your device is connected to.
- Network Configuration File:
- Network configuration files are found in /etc/netplan/.
- The default configuration is in YAML format, and it often uses NetworkManager for network management.
- These commands and locations are useful for managing and configuring network interfaces and connections in Linux.
No comments:
Post a Comment