DEV Community

Kanav Gathe
Kanav Gathe

Posted on β€’ Edited on

Day 6/90: File Permissions and Access Control Lists in Linux πŸ” #90DaysOfDevOps

Day 6: File Permissions and Access Control Lists πŸš€

Hello DevOps enthusiasts! πŸ‘‹ Welcome to Day 6 of the #90DaysOfDevOps challenge. Today, we're exploring file permissions and Access Control Lists (ACL) in Linux.

Task Solutions πŸ’»

1. Basic File Permissions

# Create and check file
touch test_file.txt
ls -ltr test_file.txt

# Change permissions (owner only)
chmod 700 test_file.txt
# OR
chmod u+rwx,go-rwx test_file.txt

# Verify changes
ls -ltr test_file.txt
Enter fullscreen mode Exit fullscreen mode

2. Permission Management Script

#!/bin/bash

# Change permissions for multiple files
change_permissions() {
    for file in "$@"
    do
        chmod 644 "$file"
        echo "Changed permissions for $file"
    done
}
Enter fullscreen mode Exit fullscreen mode

3. ACL Implementation

# Create test directory
mkdir acl_test
cd acl_test

# Set ACL for user
setfacl -m u:user1:rx file1.txt

# Set ACL for group
setfacl -m g:group1:rw file1.txt

# View ACL
getfacl file1.txt
Enter fullscreen mode Exit fullscreen mode

4. ACL Permission Script

#!/bin/bash

set_acl_permissions() {
    local file=$1
    local user=$2
    setfacl -m u:$user:rw "$file"
    echo "Set ACL for $user on $file"
}
Enter fullscreen mode Exit fullscreen mode

5. Special Permissions

# Sticky Bit
chmod +t /shared_directory

# SUID
chmod u+s /usr/bin/script

# SGID
chmod g+s /shared_directory
Enter fullscreen mode Exit fullscreen mode

6. Permission Backup

#!/bin/bash

# Backup permissions
getfacl -R /path/to/directory > permissions.acl

# Restore permissions
setfacl --restore=permissions.acl
Enter fullscreen mode Exit fullscreen mode

Permission Types Explained πŸ“

  1. Basic Permissions

    • Read (r): 4
    • Write (w): 2
    • Execute (x): 1
  2. Special Permissions

    • SUID (4000)
    • SGID (2000)
    • Sticky Bit (1000)
  3. ACL Features

    • User-specific permissions
    • Group-specific permissions
    • Default permissions
    • Inherited permissions

Key Takeaways πŸ’‘

  • File permissions are crucial for security
  • ACLs provide granular access control
  • Special permissions serve specific purposes
  • Regular permission backups are important

Linux #DevOps #Security #90DaysOfDevOps


This is Day 6 of my #90DaysOfDevOps journey. Keep securing and learning!

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
πŸŽ₯ Audio/video file upload with real-time preview
πŸ—£οΈ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
πŸ“€ Export interview's subtitles in VTT format

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Communityβ€”every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple β€œthank you” goes a long wayβ€”express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay