File Permissions and Access Control Lists (ACLs) in Linux

Sagar BhosaleSagar Bhosale
2 min read

As DevOps engineers, we dance with directories, tango with text files, and waltz with web servers. But behind the scenes, a silent guardian stands watch: file permissions. These seemingly cryptic codes determine who can read, write, and execute our precious files. Let’s unravel this mystery and explore the world of permissions and their more sophisticated sibling—the Access Control Lists (ACLs).

Traditional File Permissions: The Basics 📜

In the Linux universe, every file and directory wears a permission cloak. It’s like a secret handshake between the system and users. Here’s the breakdown:

  1. Read ®: Peeking inside the file, like reading a love letter.

  2. Write (w): Scribbling changes, rewriting that love letter.

  3. Execute (x): Performing magic—running scripts, launching programs.

These permissions apply to three entities:

  • Owner: The creator of the file, the alpha and omega.

  • Group: A squad of users with shared interests (like a book club).

  • Others: The rest of the world, the curious onlookers.

But what if we need more nuance? What if Jane from Marketing should read but not write? Enter ACLs.

Access Control Lists (ACLs): Fine-Tuning Permissions 🎛️

While traditional permissions are effective, they sometimes fall short. Imagine this scenario:

  1. Rahul: A designer who needs read-only access.

  2. Parth: A developer who needs read and write access.

  3. Demo Group: A bunch of folks who want to peek but not touch.

ACLs allow us to assign permissions for each unique user or group. Let’s dive in:

  1. Creating ACLs:

    • setfacl -m "u:rahul:r" mydesign.txt: Rahul gets read access.

    • setfacl -m "u:parth:rw" mycode.py: Path gets read and write access.

    • setfacl -m "g:demogroup:r" myreport.pdf: Demo Group gets read access.

  2. Default ACLs:

    • Set on directories, they dictate default permissions for files created within.

    • Like sprinkling magic dust on a folder: “All files born here shall inherit these permissions!”

  3. Viewing ACLs:

    • getfacl filename: Peek behind the curtain.

    • Observe the extra lines for Rahul, Parth, and the Demo Group.

Best Practices and Tips 🌟

  1. Be Kind to Users: ACLs let us fine-tune without disrupting group dynamics. Rahul can read, Parth can edit, and the Demo Group can sip virtual tea.

  2. Backups and ACLs: When you back up, remember to include ACLs. They’re part of the family too.

  3. Remove ACLs: If you change your mind, use setfacl -b. It’s like uninviting someone from a party.

Conclusion: The Symphony of Permissions 🎶

File permissions and ACLs compose a symphony. Each note matters—the read, the write, the execute. So, fellow DevOps maestros, wield your permissions wisely, and may your files dance harmoniously.

1
Subscribe to my newsletter

Read articles from Sagar Bhosale directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sagar Bhosale
Sagar Bhosale