How To Change The Owner Of a File In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Use the chown command
To change the owner of a file, use the chown command with the syntax:
chown [user][:group] <filename>
where user is the username of the new owner, and group is the new group associated with the file (optional). For example, to change the owner of a file named “file.txt” to the user “bob”, you can run:
chown bob file.txt
2. Use the sudo command
If you don’t have permissions to change the ownership of the file, you can use the sudo command to run the chown command with root privileges. For example, to change the owner of a file named “file.txt” to the user “bob”, you can run:
sudo chown bob file.txt