Mastering Linux for DevOps: Users, Permissions & Log Analysis Like a Pro! π
1οΈβ£ User & Group Management: Who's in Charge? π΅οΈββοΈ
Understanding Users & Groups
Linux is all about users and groups! The /etc/passwd
file holds user details, while /etc/group
manages group memberships.
Task: Create a DevOps User & Grant Powers
Letβs get our hands dirty! π οΈ
Create a user
devops_user
and add them to a groupdevops_team
.Creating devops_team Group-
Adding devops_user to devops_team group -
- Set a password and grant sudo access.
Grant sudo access for devops_user -
Restrict SSH login for certain users in
/etc/ssh/sshd_config
.Restrict SSH Login β οΈ
sudo vim /etc/ssh/sshd_config
Add the following lines:
DenyUsers restricted_user
AllowUsers devops_user
2οΈβ£ File & Directory Permissions: Lock it Down! π
Task: Set Up Secure Workspaces
Create a directory and file for your top-secret DevOps projects:
Create
/devops_workspace
and a fileproject_notes.txt
.Set permissions:
- Owner can edit, group can read, others have no access.
Set Permissions π
Owner can edit.
Group can read.
Others have no access.
Here, Read=4, Write=2, Execute=1. For Owner, set read & write (4+2). For Group, set read (4). For Others, set no access (0).
3οΈβ£ Log File Analysis with AWK, Grep & Sed: DevOps Detective Mode π΅οΈ
Task: Extract Insights from Logs
Logs are like breadcrumbs leading to the truth! Letβs analyze Linux_2k.log
from LogHub.
Grab the Log File :
Extract insights using commands:
Use
grep
to find all occurrences of the word "error".found no log with word error.
Use
sed
to replace all IP addresses with [REDACTED] for securityOutput : all IP addresses chnaged with [RADACTE]
Boom! Now you're officially a Log Analysis Ninja. π₯·
π― Conclusion
Linux skills are a must-have for any DevOps engineer. In this guide, we: β Explored the Linux file system & essential commands π β Managed users & groups π€ β Secured files with proper permissions π β Analyzed logs using AWK, grep, and sed π
Keep practicing, and soon you'll be automating these like a pro! π
Got any cool Linux hacks? Drop them in the comments! π