🐧 Linux / Shell Scripting
Beginner
How do chmod and chown control file permissions?
Answer
Linux file permissions are divided into three groups: owner, group, and others, each with read (4), write (2), and execute (1) bits. chmod 755 file sets owner=rwx(7), group=rx(5), others=rx(5). Symbolic form: chmod u+x file adds execute for the owner. chmod -R 644 ./dir applies recursively. chown user:group file changes the owner and group of a file. chown -R www-data:www-data /var/www recursively reassigns a web root. Use ls -l to inspect permissions — the output format is -rwxr-xr-x. Understanding permissions is critical for security and avoiding "permission denied" errors.