Linux File Ownership, ACLs, and I/O Redirects/shaare/e95DgQ
File Ownership
chown
→ Change ownershipchgrp
→ Change group
Access Control List (ACL)
setfacl
→ Set file ACLgetfacl
→ Get file ACL
Add Permission to User
setfacl -m u:user:rwx /path/to/file
setfacl -m g:group:rw /path/to/file
Recursive Inheritance from Folder
setfacl -R -m entry /path/to/dir
Remove Specific ACL Entry
setfacl -x u:user /path/to/file
Remove All ACL Entries
setfacl -b /path/to/file
Check ACL
ls -ltr
Example output:
-rw-rw-r--+
Help Commands
whatis
commandcommand --help
man
command
Add Text to a File
echo "my text" > myfile # Overwrite
cat myfile # Read the text
echo "hello" >> myfile # Append
Input and Output Redirects
3 Redirect Types
stdin
→ 0 →<
or<<
→ Feeding file content to a commandstdout
→ 1 →>
or>>
stderr
→ 2 →2>
or2>>
→ Write error output to a file
tee Command
tee
→ Output + Save
echo "test" | tee myfile
tee -a file # Append