Permissions, flags and attributes
Change uid and gid
usermod -u 2005 foo
groupmod -g 3000 foo
find / -group 2000 -exec chgrp -h foo {} \;
find / -user 1005 -exec chown -h foo {} \;
usermod -g <NEWGID> <LOGIN>
Read ttyUSB0
chmod a+rw /dev/ttyUSB0
Cd rom access
chmod u+s /usr/bin/wodim
End-to-end file access without read directory
chmod 711 <folder name>
Sticky Bit
chmod +t <folder or file name>
Restore execute bit to chmod tool
setfacl -m u::rwx,g::rx,o::x /usr/bin/chmod
/usr/lib64/ld-linux-x86-64.so.2 /usr/bin/chmod +x /usr/bin/chmod
cp --attributes-only /usr/bin/ls ./new_chmod; cat /usr/bin/chmod > ./new_chmod
install -m 755 /usr/bin/chmod ./new_chmod
rsync --chmod=ugo+x /usr/bin/chmod ./new_chmod
python -c "import os;os.chmod('/usr/bin/chmod', 0755)"
Get all files with capabilities
getcap -r /
Set capabilities in systemd Unit
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
Set default permissions
setfacl -d -m u::rwx,g::r-x,o::r-x /home/test/
Remove default permission
setfacl -k /home/test/
Remove permission
setfacl -x user_name /home/test/
Recursive
setfacl -R
Remove all acl
setfacl -bn /home/test/
View permissions
getfacl
Umask
umask
Make immutable
chattr +i <file name>
Only append
chattr +a <file name>
Kernel compress/decompress
chattr +c <file name>
Ignore when dump
chattr +d <file name>
Security remove
chattr +s <file name>
Remove with save data
chattr +u <file name>
Sync on disk
chattr +S <file name>
Show the file attributes
lsattr file_name