# 1. 🐧 Linux Fundamentals for DevOps Engineers

### 🔹 Why Linux is Important for DevOps?

Linux is the backbone of:

* Cloud servers
    
* Containers
    
* CI/CD runners
    
* Kubernetes nodes
    

---

## 🔹 Process vs Thread

* **Process**: Independent execution unit with its own memory
    
* **Thread**: Lightweight execution unit sharing process memory
    

👉 Example: One Java process running multiple threads.

---

## 🔹 Check CPU, Memory & Disk Usage

```bash
top
htop
free -m
df -h
```

---

## 🔹 Find High Memory Consuming Process

```bash
ps aux --sort=-%mem | head
```

---

## 🔹 System Monitoring Commands Explained

| Command | Use |
| --- | --- |
| top | Real-time stats |
| vmstat | CPU, memory & IO |
| free | RAM usage |
| df | Disk usage |

---

## 🔹 Check and Kill a Process

```bash
ps -ef | grep java
kill -9 <PID>
```

---

## 🔹 Find Which Service Uses a Port

```bash
netstat -tulnp | grep 8080
ss -tulnp
lsof -i :8080
```

---

## 🔹 Linux File Permissions

```bash
chmod 755 script.sh
chown user:group script.sh
```

* r=4, w=2, x=1
    

---

## 🔹 Linux Logs

```bash
tail -f /var/log/syslog
journalctl -u docker
journalctl -xe
```

---

## 🔹 Soft Link vs Hard Link

```bash
ln -s file softlink
ln file hardlink
```

| Soft | Hard |
| --- | --- |
| Cross FS | Same FS |
| Breaks | Safe |

---

## 🔹 Troubleshooting Tips

* High CPU → `top`, `htop`
    
* Low Disk → `du -sh`, `df -h`
    

---

## 🔹 Uptime & Reboot History

```bash
uptime
last reboot
```

---

## 🔹 Scheduling Jobs

```bash
crontab -e
0 2 * * * backup.sh
```

---

## 🔹 find, grep, awk, sed

```bash
find /var -name "*.log"
grep ERROR app.log
awk '{print $1}' file.txt
sed 's/dev/prod/g' file.txt
```

---

## 🎯 Key Takeaways

* Linux is non-negotiable for DevOps
    
* Monitoring & troubleshooting are daily tasks
    
* These commands are **interview favorites**
