Master shell scripting automation, cron daemon jobs, TCP/IP socket tuning, file permissions, processes vs threads scheduling, and Python administration.
SM
Written by Sachin Mehta • Founder & Principal Cloud ArchitectPrincipal cloud infrastructure specialist and systems architect. Former SRE.
Interactive Flashcards
# 1
Unreviewed
How do you write a Bash script to automate task execution?
Answer Guide
Start the script with a shebang line (e.g., "#!/bin/bash"). Make it executable using "chmod +x script.sh". Use variables, control flow blocks (if/then/fi, for/while loops), and commands. Exit scripts using exit codes (e.g., "exit 0" for success, "exit 1" for failure) to integrate with CI/CD engines.
Key Concepts Checklist
Evaluate difficulty:
# 2
Unreviewed
What is the purpose of the crontab, and what is its syntax?
Answer Guide
Crontab is used to schedule recurring background tasks in Linux. The syntax consists of 5 fields: "minute hour day_of_month month day_of_week command" (e.g., "*/5 * * * * /opt/backup.sh" runs a backup script every 5 minutes).
Key Concepts Checklist
Evaluate difficulty:
# 3
Unreviewed
How do you find and kill a process running on port 8080?
Answer Guide
Find the process ID (PID) using "lsof -i :8080" or "netstat -tulnp | grep 8080". Then, terminate the process using "kill <PID>" (or "kill -9 <PID>" if it refuses to terminate gracefully).
Key Concepts Checklist
Evaluate difficulty:
# 4
Unreviewed
Explain the difference between file permissions chmod 755 and chmod 644.
Answer Guide
"chmod 755" grants Read, Write, and Execute permissions to the Owner (7), and Read and Execute permissions to both the Group (5) and Others (5) — typically used for directories and executable scripts. "chmod 644" grants Read and Write to the Owner (6), and Read-only to Group (4) and Others (4) — standard for regular data files.
Key Concepts Checklist
Evaluate difficulty:
# 5
Unreviewed
How do you check memory and CPU utilization in real-time?
Answer Guide
Run interactive tools like "top" or "htop" to view real-time system resources and running processes. Alternatively, use "free -m" to view memory buffers, "df -h" for disk space, and "vmstat" or "iostat" for system execution stats.
Key Concepts Checklist
Evaluate difficulty:
# 6
Unreviewed
What is the difference between a process and a thread in Linux?
Answer Guide
A process is an independent execution unit with its own virtual memory space and system resources allocated by the kernel. A thread is a lightweight execution unit within a process, sharing the parent process's memory space and file descriptors, allowing faster execution but requiring synchronization.
Key Concepts Checklist
Evaluate difficulty:
# 7
Unreviewed
How do you find files larger than 100MB in the /var/log directory?
Answer Guide
Run the command "find /var/log -type f -size +100M". You can append "-exec ls -lh {} \;" to display their file sizes and metadata.
Key Concepts Checklist
Evaluate difficulty:
# 8
Unreviewed
What is the difference between systemd services and init scripts?
Answer Guide
Init scripts (SysVinit) are traditional shell scripts run sequentially during startup, making boot times slower. "systemd" is a modern system manager that handles service initialization in parallel, uses declarative configuration files (.service), tracks processes using cgroups, and manages logs via "journalctl".
Key Concepts Checklist
Evaluate difficulty:
# 9
Unreviewed
How do you append text to a file in Bash without overwriting it?
Answer Guide
Use the double greater-than operator ">>" (e.g., "echo 'log entry' >> app.log"). The single operator ">" will overwrite the entire file contents.
Key Concepts Checklist
Evaluate difficulty:
# 10
Unreviewed
What is the difference between hard links and soft links?
Answer Guide
A hard link points directly to the inode of the target file, sharing the same data block (only works on the same filesystem). A soft link (symlink) is a pointer file referencing another path (like a shortcut) and can span across filesystems and point to directories.
Key Concepts Checklist
Evaluate difficulty:
# 11
Unreviewed
How is Python used in DevOps scripting compared to Bash?
Answer Guide
Bash is excellent for quick system commands, file piping, and simple automation. Python is preferred for complex logic, processing structured data (JSON/YAML), interacting with cloud APIs (via boto3), and writing testing frameworks. It is more readable, maintainable, and supports extensive third-party libraries.
Key Concepts Checklist
Evaluate difficulty:
# 12
Unreviewed
How do you write a Bash script that creates 5 log files in the current directory containing custom messages?
Answer Guide
You can write a simple loop: "for i in {1..5}; do echo 'Log entry $i' > 'file_$i.log'; done". This loop runs 5 times, creating files file_1.log to file_5.log, writing a unique line into each.
Key Concepts Checklist
Evaluate difficulty:
Scenario Challenges
Select a scenario below to test your troubleshooting workflow.
Topic: Automated Log Cleanup
Write and schedule a bash script that purges log files older than 7 days from the /var/log/app folder.
Write find /var/log/app -type f -name "*.log" -mtime +7 -exec rm -f {} \; inside a script file.Click to select
Save the file to /usr/local/bin/cleanup.sh and apply execute permissions: chmod +x.Click to select
Open crontab -e and configure: 0 2 * * * /usr/local/bin/cleanup.sh to run daily at 2 AM.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: Python Disk Usage Alerting
Create a Python script that checks root partition disk utilization and sends alert payloads to a Slack Webhook when usage is >90%.
Import shutil and calculate disk statistics: total, used, free.Click to select
Compute usage percentage and construct a conditional check for usage > 90.Click to select
Import requests and send a POST request containing JSON alert data to the webhook URL.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: TCP Port Exhaustion Recovery
An application is dropping network requests under peak loads with socket error warnings. Reclaim connection pools.
Execute ss -s to analyze the sockets counts in TIME_WAIT state.Click to select
Open /etc/sysctl.conf and expand net.ipv4.ip_local_port_range boundaries.Click to select
Add net.ipv4.tcp_tw_reuse = 1 to permit socket reuse, then apply changes with sysctl -p.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: CPU Steal Time Contention
A cloud-hosted app is running extremely slow. System diagnostics report high CPU steal time. Troubleshoot the VM.
Run top or vmstat 1 to monitor the CPU "%st" status column values.Click to select
Identify that host-level hypervisor resource contention is starving the virtual instance.Click to select
Stop and start the cloud instance to migration it onto a healthy host node, or scale up tiers.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
Topic: Process Port Conflict
Find the process occupying port 8080 and terminate it to free up the socket for another application.
Run lsof -i :8080 to locate the active Process ID (PID).Click to select
Inspect process properties using ps -ef | grep <PID> to verify service identity.Click to select
Execute kill -15 <PID> (or kill -9 <PID> if unresponsive) to reclaim the port.Click to select
Selected Sequence
No steps selected yet. Click options above in sequence.
We value your privacy
We use cookies to analyze site traffic, personalize content, and support our free educational platforms. By clicking "Accept All", you consent to our use of cookies.