What is the difference between chmod and chown?

Answer

chmod (change mode) changes the permission bits of a file — what actions are allowed for owner, group, and others. chown (change owner) changes the ownership of a file — who the owner and group are. Example: chown www-data:www-data /var/www/html sets both user and group ownership. chown user file changes only the user owner. chown :group file changes only the group. chown -R user:group /dir changes ownership recursively. Only root (or the file owner for chmod) can change these attributes. Both often need to be used together when deploying applications.