Minggu, 14 Desember 2025

Chown -

: sudo chown john report.txt This makes the user "john" the owner of the file.

💡 : Use the --reference flag to copy ownership from one file to another without typing out names: chown --reference=original.txt newfile.txt . : sudo chown john report

: When moving files to /var/www , you often need to chown them to www-data so the web server can serve them. : The name or numeric ID of the new owner

Understanding ownership is critical for troubleshooting "Permission Denied" errors, especially in web development or server administration. : sudo chown john report

Because chown can lock you out of your own files or break system services, keep these tips in mind:

At its core, chown requires two pieces of information: the new owner and the target file. chown [OPTIONS] USER[:GROUP] FILE Use code with caution. : The name or numeric ID of the new owner. GROUP : (Optional) The name or ID of the new group. FILE : The specific file or directory you want to modify. Common Use Cases

: If a user has been deleted but their files remain, you can still use their numeric UID (e.g., chown 1001 file.txt ) to manage them.