How To Change Owner Of 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. Make sure you are logged in as the root user.
2. Use the command line to navigate to the directory containing the file.
3. Use the command chown to change the owner of the file. The syntax is as follows:
chown [new-owner][file]
For example, if the file is called test.txt and you want to change it’s owner to user1, the command should be:
chown user1 test.txt
4. To change the owner of the directory and all of its contents, use the -R flag. This will recursively change the owner of the directory and all of its contents. The syntax is as follows:
chown -R [new-owner] [directory]
For example, if you want to change the owner of the directory mydir to user1, the command should be:
chown -R user1 mydir