Linux for DevOps: Users, Permissions & Log Analysis (with Practical Tasks + Log File)

Whether you're starting with Linux or diving deeper into DevOps workflows, this guide walks you through real-world, hands-on tasks for managing users, permissions, and analyzing logs β all essentials for DevOps engineers.
1οΈβ£ User & Group Management in Linux π§βπ€βπ§
Managing users and groups is foundational to Linux security and DevOps automation. Letβs walk through real tasks:
π§ Task 1: Create a User and Group
bashCopyEditsudo groupadd devops_team
sudo useradd -m -s /bin/bash -g devops_team devops_user
-m
: creates home directory-s /bin/bash
: assigns Bash shell-g
: assigns the group
π Task 2: Set a Password
bashCopyEditsudo passwd devops_user
Choose a secure password β it enables SSH login.
π‘οΈ Task 3: Grant Sudo Access
bashCopyEditsudo usermod -aG sudo devops_user
This gives devops_user
administrative (sudo) privileges.
π« Task 4: Restrict SSH Login for Certain Users
To block SSH login for specific users (e.g., test users), edit this file:
bashCopyEditsudo nano /etc/ssh/sshd_config
Add at the bottom:
bashCopyEditDenyUsers testuser guest
Then restart the SSH service:
bashCopyEditsudo systemctl restart ssh
β
Tip: Use id username
or groups username
to verify assignments.
2οΈβ£ File & Directory Permissions π
Understanding permissions helps secure your files and maintain correct access levels across DevOps teams.
π Task: Create Workspace and File
bashCopyEditmkdir /devops_workspace
touch /devops_workspace/project_notes.txt
π Set Custom Permissions:
Owner: edit (read/write)
Group: read only
Others: no access
bashCopyEditchmod 640 /devops_workspace/project_notes.txt
π Verify:
bashCopyEditls -l /devops_workspace/
Expected output:
bashCopyEdit-rw-r----- 1 devops_user devops_team 0 Jul 10 14:20 project_notes.txt
π Bonus: Permission Truth Table
Permission | Binary | Meaning |
7 | 111 | rwx (full access) |
6 | 110 | rw- (read/write) |
5 | 101 | r-x (read/execute) |
4 | 100 | r-- (read only) |
2 | 010 | -w- (write only) |
0 | 000 | --- (no access) |
Use this to understand what chmod 640
really means:
6
(rw-) β Owner4
(r--) β Group0
(---) β Others
3οΈβ£ Log File Analysis with awk
, grep
, and sed
π
In DevOps, analyzing logs is π to troubleshooting and alerting.
π Log File for Practice
Since many servers donβt have enough logs, I used this test log file:
π Download Linux_2k.log
π οΈ Task 1: Find Errors Using grep
bashCopyEditgrep -i error Linux_2k.log
-i
: ignore caseShows all lines containing "error"
π§ Task 2: Extract Timestamps and Log Levels with awk
bashCopyEditawk '{print $1, $2, $3, $6}' Linux_2k.log
- This extracts date + log level (assuming the format fits this pattern)
π΅οΈ Task 3: Replace All IPs with [REDACTED]
Using sed
bashCopyEditsed -E 's/([0-9]{1,3}\.){3}[0-9]{1,3}/[REDACTED]/g' Linux_2k.log
- Hides all IPs for privacy and security β useful for public demos/log sharing.
π¬ Letβs Talk!
I just completed these tasks myself β if you're a beginner or DevOps learner, give these a try!
What command did you find most useful?
Want me to post a script that automates this entire setup?
Have your own favorite
awk
orsed
trick? Share it below β¬οΈ
π§ Final Tip: Learn by Doing
Even basic commands like chmod
, awk
, and groupadd
are incredibly powerful when applied in real-world setups.
Stay consistent, explore logs, write shell scripts, and you'll be automating your infrastructure in no time π₯
π Want More?
Iβm planning a Part 2 on:
- Volumes
Follow me on Hashnode or connect on LinkedIn to get it first!
Subscribe to my newsletter
Read articles from Vivek Umrao directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
