Each file or directory in Linux has an owner, group, and permissions that allow who can read, write, and execute the file.
If you wish to change the owner for a file or directory, you can make use of the chown command. Using the chown command you can change both the owner user and the owner group for a file or directory.
Syntax:
sudo chown <new-user-name>:<new-user-group> file/directory
Example 1 : Change owner only
File:
sudo chown code2care /Users/c2ctech/data/data.csv
Directory:
sudo chown code2care /Users/c2ctech/data
Example 2: Change owner group only
File:
sudo chown :devs /Users/c2ctech/data/data.csv
Directory:
sudo chown :devs /Users/c2ctech/data
Example 3: Change both owner and group
File:
sudo chown code2care:devs /Users/c2ctech/data/data.csv
Directory:
sudo chown code2care:devs /Users/c2ctech/data

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!