Linux chown Command
The Linux chown (full spelling in English: change owner) command is used to set the file owner and associated group.
Linux/Unix is a multi-user, multi-tasking operating system where all files have an owner. The chown command is used to change the owner of specified files to a designated user or group. The user can be a username or user ID, and the group can be a group name or group ID. The files are a space-separated list of files to change permissions for, and it supports wildcard characters.
The chown command requires superuser root
privileges to execute.
Only the superuser and the file owner belonging to the group can change the file's associated group. Non-superusers may need to use the chgrp command to set the associated group.
Usage Permissions: root
Syntax
chown [-cfhvR] [--help] [--version] user[:group] file...
Parameters:
- user: The new owner's user ID
- group: The new owner's group (group)
- -c: Display information about the changes made
- -f: Ignore error messages
- -h: Fix symbolic links
- -v: Display detailed processing information
- -R: Process specified directories and all subdirectories
- --help: Display help information
- --version: Display the version
Examples
chown root /var/run/httpd.pid
Set the owner of the file file1.txt to tutorialpro and the group to tutorialprogroup:
chown tutorialpro:tutorialprogroup file1.txt
Set the owner of all files and subdirectories in the current directory to tutorialpro and the group to tutorialprogroup:
chown -R tutorialpro:tutorialprogroup *
Set the associated group of /home/tutorialpro to 512 (group ID) without changing the owner:
chown :512 /home/tutorialpro