Change Ownership to Specific User

chown <user> <file>
chown <user> <dir>
# -R: Recursive
chown -R <user> <dir>

Examples

chown tester example.txt
chown tester ./example
chown -R tester ./example


Change Ownership to Specific Group

chown :<group> <file>
chown :<group> <dir>
# -R: Recursive
chown -R :<group> <dir>

Examples

chown :testers example.txt
chown :testers ./example
chown -R :testers ./example


Change Ownership to Specific User&Group

We can give ownership of file/directory to specific both use and group at the same time.

chown <user>:<group> <file>
chown <user>:<group> <dir>
# -R: Recursive
chown -R <user>:<group> <dir>

Examples

chown tester:testers example.txt
chown tester:testers ./example
chown -R tester:testers ./example