Sitemap

πŸ” Secure Shared Logging: Creating a Centralized Logs Directory for Multiple Linux Users

2 min readMay 13, 2025

--

Press enter or click to view image in full size

🎯 Objective

In multi-user Linux environments, there are often requirements where several users must be able to submit logs or reports in a shared location β€” without having the ability to modify or delete each other’s files. This project demonstrates how to configure such a secure, centralized directory called /central_logs.

πŸ” Project Overview

We aim to:

  • Create a shared directory /central_logs
  • Allow all users to write (add) their own files
  • Prevent users from modifying or deleting each other’s files
  • Let all users list the contents of the directory

To simulate this, we will create two test users: user1 and user2.

βš™οΈ Step-by-Step Implementation

1️⃣ Create the Central Directory

sudo mkdir /central_logs

2️⃣ Create Test Users

sudo useradd user1
sudo useradd user2
# Set passwords
sudo passwd user1
sudo passwd user2

βœ… Note: If the users already exist, skip this step.

3️⃣ Set Group Ownership and Permissions

We’ll use the Sticky Bit concept β€” commonly used in directories like /tmp.

sudo chmod 1777 /central_logs

πŸ” What does 1777 mean?

  • 1 – Sticky Bit: Only the file's owner or root can delete or rename their own files.
  • 7 – Read, write, execute for owner
  • 7 – Read, write, execute for group
  • 7 – Read, write, execute for others

This allows:

  • All users to write to the directory
  • Only the owner of a file to modify or delete it

πŸ§ͺ Testing and Verification

βœ… Switch to user1 and Create a File

su - user1
echo "Log file from user1" > /central_logs/user1_log.txt

βœ… Switch to user2 and Try to Delete user1's File

su - user2
rm /central_logs/user1_log.txt

Output:

rm: cannot remove '/central_logs/user1_log.txt': Operation not permitted

πŸŽ‰ Success! user2 cannot delete user1's file.

βœ… Now, Let user2 Create Their Own File

echo "Log file from user2" > /central_logs/user2_log.txt

βœ… Both Users Can List Files

ls -l /central_logs

Example output:

-rw-r--r-- 1 user1 user1 23 May 13 15:00 user1_log.txt
-rw-r--r-- 1 user2 user2 23 May 13 15:01 user2_log.txt

πŸ“˜ Real-World Use Cases

  • Log aggregation from multiple users/applications
  • Shared reporting directory
  • Assignment submissions in training environments
  • Secure drop folders in enterprise settings.

🧠 Bonus Tips

  • Use ACLs (Access Control Lists) for even more granular permission control
  • Monitor file activity using tools like auditd or inotify

πŸ“Œ Conclusion

This setup offers a simple yet powerful way to allow multiple users to collaborate by writing to a shared directory without compromising file integrity or security. Sticky Bit is your friend in scenarios like this!

--

--