Sobes.tech
Junior — Middle

How can you change the owner of a file in an operating system?

sobes.tech AI

Answer from AI

In Unix-based operating systems (Linux, macOS), the chown command is used to change the owner of a file.

Syntax:

chown [new_owner][:new_group] path_to_file

Example:

chown user1 file.txt       # change owner to user1
chown user1:group1 file.txt # change owner to user1 and group to group1

This command usually requires superuser (root) privileges, so it is often used with sudo:

sudo chown user1 file.txt

Thus, chown allows managing the owner and group of a file, which is important for access control and security.