- Owner (user) – The user who created the file.
- Group – Users who share access to the file.
- Others – Everyone else.
Permission Basics: Read, Write, Execute
Permissions come in three flavors for each category (owner, group, others):
Permission Meaning
| Permission | Meaning |
|---|---|
| Read (r) | View file or list folder contents |
| Write (w) | Modify file or add/delete in folder |
| Execute (x) | Run file (if program) or enter folder |
Check file permissions using:
# ls -l filename
Example output:
-rwxr-xr--
- - = File type (d for directory)
- rwx = Owner: full access
- r-x = Group: read/execute, no write
- r-- = Others: read-only
You can tweak file access in two modes:
Symbolic Mode (Easy Adds/Removes)
Letters represent categories:
- u = owner
- g = group
- o = others
- a = all
# chmod u+r filename # Owner gains read permission
# chmod g-w filename # Group loses write permission
# chmod o+x filename # Others gain execute permission
Numeric (Octal) Mode
Assign numbers:
- Read = 4
- Write = 2
- Execute = 1
| Number | Permissions | Meaning |
|---|---|---|
| 7 | rwx | Full access |
| 6 | rw- | Read + write |
| 5 | r-x | Read + execute |
| 4 | r-- | Read only |
Example:
# chmod 755 filename
- Owner = 7 (rwx)
- Group = 5 (r-x)
- Others = 5 (r-x)
Ownership: chown and chgrp
Files can change ownership if you’re root:
# chown newuser filename # Change file owner
# chgrp newgroup filename # Change file group
Special Permissions:
AIX has advanced flags to control behavior:
- Setuid (s): Runs the file as the file owner instead of the caller. Example: rwsr-xr-x
- Setgid (s): New files inherit the folder’s group.
- Sticky bit (t): Only the owner can delete a file in the directory. Common in /tmp:
That t keeps your temp files safe from accidental deletion by others.
Hidden Files:
Files starting with a dot (.) are hidden—ideal for configuration files like .bashrc or .ssh/.
# ls -l → skips hidden files
# ls -la → shows all files, including hidden ones
Example:
-rw-r--r-- 1 user group 123 Sep 26 12:00 file.txt
-rw-r--r-- 1 user group 50 Sep 26 12:05 .hiddenfile
Why hide?
# touch .myhiddenfile # Create a hidden file
# echo "Hello" > .myhiddenfile
# cd .ssh # Enter a hidden directory
# rm .hiddenfile # Delete hidden file
-rw-r--r-- 1 user group 123 Sep 26 12:00 file.txt
-rw-r--r-- 1 user group 50 Sep 26 12:05 .hiddenfile
Why hide?
- Prevent accidental modifications
- Keep configuration files safe
- Permissions still apply (e.g., chmod 600 .hiddenfile = owner-only read/write)
# touch .myhiddenfile # Create a hidden file
# echo "Hello" > .myhiddenfile
# cd .ssh # Enter a hidden directory
# rm .hiddenfile # Delete hidden file
No comments:
Post a Comment