Since you want to explore further, let's look at some advanced scenarios and "Pro Tips" that system administrators use to manage permissions.
1. The "X-Ray" View: stat
While ls -l is great, the stat command gives you a much more detailed "ID card" for a file, including the numeric notation.
Try this:
stat example.txt
Look for the "Access" line. It will show you the permissions in both formats, like (0700/-rwx------).
2. Symbolic Notation (The "Calculator-Free" Way)
Sometimes you don't want to do the math. You can use letters like u (user), g (group), o (others), and a (all).
- Add permission:
chmod u+x filename(Add execute to user) - Remove permission:
chmod g-w filename(Remove write from group) - Set exactly:
chmod a=r filename(Everyone can only read, nothing else)
Try it:
Make your example.txt readable by everyone without using numbers:
chmod a+r example.txt
ls -l example.txt
3. Special Permissions: The "Sticky Bit"
There is a special permission used for folders like /tmp where everyone can write files, but nobody can delete someone else's files.
- It is represented by a
tat the end (e.g.,drwxrwxrwt). - Without this, if a folder had
777permissions, any user could delete the work of any other user!
4. Permission Dependencies
This is a common point of confusion for beginners. Remember these rules:
- To delete a file: You actually need Write permission on the Parent Directory, not the file itself! (Because deleting a file is technically "modifying" the folder's list).
- To copy a file: You need Read on the source file and Write/Execute on the destination directory.
5. Practical Challenge for You
Try to create a "Secret Dropzone" folder:
- Create a folder:
mkdir dropzone - Set permissions so you can do everything, but others can only put files in it and not see what's inside.
- The Code:
chmod 733 dropzone7(Owner): Read, Write, Execute (Full control)3(Others): Write (2) + Execute (1) = 3.- Effect: They can
cdinto it and create files, butlswill fail for them because they don't have Read (4) permission!
Would you like to try applying these settings to a directory and see if you can still access files inside it?