← Users & Permissions
Linux · Users & Permissions

How to change file ownership in Linux

Change the owner and group of files with chown and chgrp, including recursive changes done safely.


Change who owns a file or directory. chown sets the owner (and optionally group); chgrp sets only the group. Run as root to change to another owner.

chown -R on the wrong path (for example / or a system directory) can break the whole system. Double-check the target path before running a recursive change.

# Change owner
sudo chown <user> <file>

# Change owner and group
sudo chown <user>:<group> <file>

# Change only the group
sudo chgrp <group> <file>

# Recursively (check the path twice first)
sudo chown -R <user>:<group> /opt/app

# Verify
ls -l <file>
LinuxchownOwnership