Use Python to check file permissions and ensure important files are secure.
import os
files = ["data.txt", "/etc/passwd"]
for f in files:
if os.path.exists(f):
permissions = oct(os.stat(f).st_mode)[-3:]
print(f"{f} permissions: {permissions}")
else:
print(f"{f} does not exist")
Checking permissions is key for defending against unauthorized access.
Next Lesson →