Understanding permissions
-rwxr-xr--
-: File type (-= file,d= directory)rwx: Owner permissions (read, write, execute)r-x: Group permissionsr--: Others permissions
Give execute permission
chmod +x script.sh
Set specific permissions (755)
chmod 755 file.txt
7(Owner): read + write + execute5(Group): read + execute5(Others): read + execute
Common permission codes
644: Read/write for owner, read-only for others755: Executable for all, writable by owner600: Private file, only owner can read/write777: Full access for everyone (Avoid in production!)
Recursively change permissions
chmod -R 755 /var/www/html
Change file owner
chown username file.txt
Change owner and group
chown username:groupname file.txt
Recursively change ownership
chown -R www-data:www-data /var/www
View file permissions
ls -la file.txt
Set default permissions for new files
umask 022