Mastering Linux for DevOps: Users, Permissions & Log Analysis Like a Pro! πŸš€

Mastering Linux for DevOps: Users, Permissions & Log Analysis Like a Pro! πŸš€

Β·

2 min read

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 group devops_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 file project_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 security

      Output : 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! πŸ‘‡

Β