# 🚀Day 2: Users, Processes, systemctl & journald

**Series:** 30 Days DevOps Interview Preparation  
**Author:** Tathagat Gaikwad

---

## 👋 Introduction

Welcome to **Day 2** of the **30 Days DevOps Interview Preparation Challenge!**  
Today, we go beyond file systems and permissions and explore how Linux handles **users, processes, service management (systemctl)**, and **logging (journald)**.

These are key skills in troubleshooting, monitoring, and managing systems as a DevOps or Cloud Engineer.

---

## 🔐 Linux Users & Groups

### 🧑 Types of Users

* **Root**: The superuser with full access
    
* **System Users**: Created by the OS or services (like `nginx`, `mysql`)
    
* **Normal Users**: Created for real human logins
    

### 📄 Important Files

* `/etc/passwd` – User account information (username, UID, shell)
    
* `/etc/shadow` – Password hashes and password expiration
    
* `/etc/group` – Group information
    

### 🔧 Common User Commands

```plaintext
# Add a new user
sudo useradd devops_user

# Set password for a user
sudo passwd devops_user

# Modify user (add to group)
sudo usermod -aG docker devops_user

# Show user groups
groups devops_user

# Get user info
id devops_user
```

---

## ⚙️ Linux Processes

A **process** is any running instance of a program.

### 🧩 Process Attributes

* **PID (Process ID)**: Unique identifier
    
* **PPID (Parent PID)**: ID of parent process
    
* **Nice Value**: Priority of a process
    
* **State**: Running, Sleeping, Zombie, etc.
    

### 📈 Useful Process Commands

```plaintext
ps aux             # Show all running processes
top                # Live system view
htop               # Interactive process viewer (must install)
kill -9 <pid>      # Force kill process
nice -n 10 <cmd>   # Start a process with priority
renice -n -5 <pid> # Change priority of existing process
```

### 🧪 Practice

* Find top CPU-consuming process using `top`
    
* Kill a hanging process using `kill -9`
    
* Launch a background process: `sleep 300 &`
    

---

## 🔄 systemctl (Systemd Service Manager)

**systemctl** is the command-line tool to control services in **SystemD**\-based Linux distributions.

### 🔧 Common Commands

```plaintext
# Check status of a service
sudo systemctl status sshd

# Start / Stop / Restart a service
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

# Enable/disable service to run at boot
sudo systemctl enable docker
sudo systemctl disable docker

# Reload systemd manager config
sudo systemctl daemon-reexec
```

### ✅ Tip:

Use `systemctl is-enabled <service>` to verify startup behavior.

---

## 📜 journald – SystemD Logging

SystemD includes **journald**, a logging service that replaces traditional `syslog`.

### 🔍 Use journalctl to View Logs

```plaintext
# All logs
journalctl

# Logs for a specific unit/service
journalctl -u docker

# Logs since last boot
journalctl -b

# Follow live logs like tail
journalctl -f

# Show logs for specific time
journalctl --since "2 hours ago"
```

### 🧪 Practice

* Stop a service and view its failure log with `journalctl -xe`
    
* Monitor system logs live while restarting a service
    

---

## 🎯 Interview Preparation

### 🧠 Sample Questions:

* What’s the difference between `/etc/passwd` and `/etc/shadow`?
    
* How can you check which groups a user belongs to?
    
* What is the difference between `ps`, `top`, and `htop`?
    
* How would you troubleshoot a service that fails to start?
    
* How do you inspect logs of a service started via systemd?
    

---

## ✅ Wrap-Up

Understanding how Linux handles users, processes, and system services is critical in debugging, managing workloads, and automating infrastructure in a DevOps role.

**#DevOps #Linux #Systemctl #ProcessManagement #Journalctl #30DaysOfDevOps #InterviewPrep #ShellScripting #CloudEngineer**
