Added Zombie Ps Docs

This commit is contained in:
2026-04-14 18:02:10 +03:30
parent ded4f55fb8
commit edea1fe9e8
4 changed files with 196 additions and 69 deletions

View File

@@ -0,0 +1,46 @@
## Zombie Processes
### What is a Zombie Process?
In Linux/Unix operating systems, when a process ends, its execution is halted, but it leaves behind an entry in the process table. This entry contains the process's exit status, which needs to be read by its parent process.
A **zombie process** (or defunct process, indicated by the `Z` state in `ps` output) is a child process that has completed its execution, but its parent process has not yet called the `wait()` or `waitpid()` system calls to read its exit status. Because the parent hasn't acknowledged the death, the OS keeps the child's entry in the process table.
### The Effect of Zombie Processes
At first glance, a zombie process seems harmless:
* It consumes **$0$** CPU resources.
* It consumes **$0$** Memory (RAM).
**The Danger: PID Exhaustion**
The only resource a zombie consumes is an entry in the OS process table and a Process ID (PID). Operating systems have a maximum limit of PIDs available (often $32768$ by default, though tunable in `sysctl`). If a poorly written parent process continuously spawns children and never reaps them, the system will eventually run out of available PIDs.
When PID exhaustion occurs, the OS cannot create any new processes. You won't be able to SSH into the server, execute basic commands, or spawn new application threads, effectively bringing the system down.
### How to Identify Zombies
* **Using `top`:** The header will explicitly show a counter for zombie processes.
* **Using `ps`:** List the PIDs of all processes with a `Z` (Zombie) state:
```bash
ps aux | awk '{ print $8 " " $2 }' | grep -w Z
```
### How to "Kill" a Zombie Process
**Important Rule:** You cannot kill a zombie process directly. Even `kill -9 <zombie_pid>` (SIGKILL) will not work because the process is already dead. To clear a zombie, you must deal with its **parent process**.
**Step 1: Find the Parent Process ID (PPID)**
Find out which process spawned the zombie:
```bash
ps -o ppid= -p <zombie_pid>
```
**Step 2: Ask the parent to reap the child**
Send a `SIGCHLD` signal to the parent process. This acts as a gentle reminder for the parent to execute the `wait()` system call and clean up its children.
```bash
kill -s SIGCHLD <parent_pid>
```
**Step 3: Kill the Parent Process (If Step 2 fails)**
If the parent process is poorly programmed, hung, or ignoring the `SIGCHLD` signal, your only operational choice is to kill the parent process:
```bash
kill -9 <parent_pid>
```
*Note on Step 3:* When the parent dies, the zombie process becomes an "orphan". The OS kernel automatically reassigns all orphan processes to the init system (usually `systemd` or `init`, which is PID $1$). PID $1$ is specifically designed to routinely execute `wait()` and will instantly reap the zombie, finally clearing it from the process table.

View File

@@ -1,18 +1,18 @@
# ⚙️ PS Command # PS Command
The `ps` (process status) command is used to **view running processes** on a Linux system. Its useful for monitoring and troubleshooting tasks. The `ps` (process status) command is used to **view running processes** on a Linux system. Its useful for monitoring and troubleshooting tasks.
--- ---
## 🧾 Basic Usage ## Basic Usage
### 🔍 Show tasks in the current shell ### Show tasks in the current shell
```bash ```bash
ps ps
``` ```
### 🔍 Show tasks in the current shell with **full info** ### Show tasks in the current shell with **full info**
```bash ```bash
ps -f ps -f
@@ -20,9 +20,9 @@ ps -f
--- ---
## 🌍 View System-Wide Processes ## View System-Wide Processes
### 📋 Show **all** processes ### Show **all** processes
```bash ```bash
ps -A ps -A
@@ -32,17 +32,17 @@ ps -e
--- ---
### 👤 Show tasks by **specific user** ### Show tasks by **specific user**
```bash ```bash
ps -u <username> ps -u <username>
``` ```
📌 Replace `<username>` with the actual user name. Replace `<username>` with the actual user name.
--- ---
### 📊 Show **detailed info for all** tasks ### Show **detailed info for all** tasks
```bash ```bash
ps aux ps aux
@@ -50,7 +50,7 @@ ps aux
--- ---
## 📘 Output Fields Explained ## Output Fields Explained
| Column | Description | | Column | Description |
| --------- | -------------------------------------------------- | | --------- | -------------------------------------------------- |
@@ -58,22 +58,20 @@ ps aux
| `PID` | Process ID | | `PID` | Process ID |
| `%CPU` | CPU usage percentage | | `%CPU` | CPU usage percentage |
| `%MEM` | Memory usage percentage | | `%MEM` | Memory usage percentage |
| `STAT` | Process state: `R` (running), `S` (sleeping), etc. | | `STAT` | Process state: `R` (running), `S` (sleeping), `Z` (zombie), etc. |
| `START` | Time when the process started | | `START` | Time when the process started |
| `TIME` | Total CPU time used | | `TIME` | Total CPU time used |
| `COMMAND` | Command that started the process | | `COMMAND` | Command that started the process |
### 📑 Show List Jobs ### Show List Jobs
```bash ```bash
jobs jobs
``` ```
### 🔄Move Process From Background To Forground ### Move Process From Background To Foreground
```bash ```bash
fg fg
``` ```

188
README.md
View File

@@ -1,57 +1,111 @@
# 🐧 DevOps Documents # 🐧 DevOps Knowledge Base
A curated collection of scripts, configuration files, and guides for managing and configuring Linux-based systems. This personal repository serves as a comprehensive knowledge base to simplify deployment, automation, monitoring, security, and much more. > 🚀 *Your centralized hub for Linux, DevOps, and Infrastructure mastery*
A structured and ever-growing collection of **scripts, configurations, and hands-on guides** designed to simplify:
* ⚙️ Automation
* 🐳 Containerization
* 📊 Monitoring
* 🔐 Security
* ☁️ Cloud & Infrastructure
--- ---
## 📂 Repository Structure ## 🧭 Quick Navigation
### ⚙️ Configuration Management & Automation ### ⚙️ Configuration & Automation
- [Ansible](./Configuration%20Management%20&%20Automation/Ansible)
- [CronJob](./Configuration%20Management%20&%20Automation/CronJob)
### 🐳 Containerization & Orchestration * 🔹 Ansible
- [Docker](./Containerization%20&%20Orchestration/Docker) * 🔹 CronJobs
- [Kubernetes (In Progress)](./Containerization%20&%20Orchestration/Kubernetes)
### 🐳 Containers & Orchestration
* 🔹 Docker
* 🔹 Kubernetes *(Work in Progress)*
* 🔹 Dozzle
### ☁️ Cloud
* 🔹 AWS
### 🗄️ Databases ### 🗄️ Databases
- [PostgreSQL](./Databases/Postgresql)
* 🔹 PostgreSQL
* 🔹 MariaDB
### ⚡ Caching ### ⚡ Caching
- [Redis](./Caching/redis)
* 🔹 Redis
### 💻 Code Management ### 💻 Code Management
- [Git](./Code%20Management/Git)
* 🔹 Git
* 🔹 GitLab (CI/CD, Cache, Baremetal Setup)
### 🔀 High Availability ### 🔀 High Availability
- [HAProxy](./High%20Availability/Ha-Proxy)
* 🔹 HAProxy
### 📊 Monitoring & Logging ### 📊 Monitoring & Logging
- [Grafana](./Monitoring%20&%20Logging/Grafana)
- [LibreNMS](./Monitoring%20&%20Logging/Librenms)
- [Netdata](./Monitoring%20&%20Logging/Netdata)
- [Zabbix](./Monitoring%20&%20Logging/Zabbix)
### 🔐 Networking & Security * 🔹 Grafana
- [iptables](./Security%20&%20Networking/Iptables) * 🔹 Zabbix
- [Nmap](./Security%20&%20Networking/Nmap) * 🔹 Netdata
- [Nginx](./Security%20&%20Networking/Nginx) * 🔹 LibreNMS
- [File Sharing](./Security%20&%20Networking/FileSharing) * 🔹 ELK Stack
### 📦 Storage ### 🔐 Security & Networking
- [NFS](./Storage/NFS)
### 🧠 System & Kernel Management * 🔹 iptables
- [Kernel](./System%20&%20Kernel%20Management/Kernel) * 🔹 Nmap
* 🔹 tcpdump
* 🔹 hping3
* 🔹 File Sharing (SMB)
### 📦 Storage & Object Systems
* 🔹 NFS
* 🔹 MinIO
* 🔹 S5CMD
### 🧠 Linux & System Administration
* 🔹 Bash Scripting
* 🔹 System Administration
* 🔹 File Synchronization (rsync)
* 🔹 Terminal Multiplexers (screen)
### 🔁 Web Servers & Reverse Proxies ### 🔁 Web Servers & Reverse Proxies
- [Nginx (Web)](./Web%20Servers%20&%20Reverse%20Proxies/Nginx)
### 🤖 Bots & Automation Tools * 🔹 Nginx
- [Telegram Bot](./Bots%20&%20Automation%20Tools/TelegramBot) * 🔹 Certbot
* 🔹 Nextcloud
### 📝 Miscellaneous ### 🔑 Password Management
- [Info](./Info)
* 🔹 Vaultwarden
### 🖥️ Virtualization & Dev Environments
* 🔹 Vagrant
### 🤖 Automation & Bots
* 🔹 Telegram Bot
---
## 🗂️ Documentation Structure
This repository is organized into **topic-based directories**, each containing:
* 📘 Step-by-step guides
* ⚡ Real-world configurations
* 🧪 Practical examples
* 🧾 Ready-to-use scripts
> 💡 Each section is self-contained—start anywhere based on your needs.
--- ---
@@ -60,47 +114,73 @@ A curated collection of scripts, configuration files, and guides for managing an
```bash ```bash
git clone https://github.com/RadinPirouz/linux-documents.git git clone https://github.com/RadinPirouz/linux-documents.git
cd linux-documents cd linux-documents
```` ```
* Explore each folder for setup guides, scripts, and configuration examples. 📌 Then:
* Follow individual README or documentation files inside each directory before running any scripts.
1. Navigate to the relevant category
2. Open the `.md` documentation files
3. Follow instructions step-by-step
--- ---
## 📌 Notes ## 🧪 Philosophy
* Tested on **Debian/Ubuntu** and **CentOS/RHEL**-based distributions. This knowledge base is built on:
* ⚠️ Always review and test configurations in a staging environment before applying to production.
* ✅ Practical, real-world usage
* ✅ Minimal theory, maximum application
* ✅ Copy-paste friendly configs
* ✅ Modular learning approach
---
## ⚠️ Important Notes
* 🐧 Tested on:
* Debian / Ubuntu
* CentOS / RHEL
* 🚨 Always:
* Review configs before running
* Test in staging environments
* Understand before deploying to production
--- ---
## 🤝 Contributing ## 🤝 Contributing
Contributions are welcome! 🛠️ Want to improve this knowledge base? You're welcome!
1. Fork the repository. ```bash
2. Create a new branch: # 1. Fork the repo
`git checkout -b feature/YourFeature` # 2. Create your feature branch
3. Commit your changes: git checkout -b feature/your-feature
`git commit -m "Add new config for X"`
4. Push to the branch:
`git push origin feature/YourFeature`
5. Open a Pull Request 🙌
Please ensure your code is tested and well-documented. # 3. Commit changes
git commit -m "Add: your feature"
# 4. Push to GitHub
git push origin feature/your-feature
```
Then open a Pull Request 🙌
--- ---
## 📬 Contact ## 📬 Contact & Support
Questions or feedback? Reach out: * 💬 Telegram: [https://t.me/RadinPirouz](https://t.me/RadinPirouz)
* 🐛 Issues: [https://github.com/RadinPirouz/linux-documents/issues](https://github.com/RadinPirouz/linux-documents/issues)
* 💬 Telegram: [@RadinPirouz](https://t.me/RadinPirouz)
* 🐛 GitHub Issues: [Open an Issue](https://github.com/RadinPirouz/linux-documents/issues)
--- ---
## ⭐ Support ## ⭐ Support the Project
If you find this repository useful, please give it a ⭐ and share it with others! If this helped you:
* ⭐ Star the repository
* 🔁 Share it with others
* 🧠 Use it, improve it, contribute back

View File

@@ -0,0 +1,3 @@
```bash
sudo apt install bind9
```