How to change file ownership?

QuestionsQuestions8 SkillsProPermissions of FilesAug, 25 2025
0144

To change file ownership in Linux, you can use the chown command. Here’s how to do it:

  1. Open the terminal.

  2. Use the chown command with the desired owner and group. The syntax is:

    sudo chown owner:group filename
    • owner is the new owner's username.
    • group is the new group name (optional).
    • filename is the name of the file whose ownership you want to change.
  3. Example: To change the ownership of a file named example.txt to user john and group staff, you would run:

    sudo chown john:staff example.txt
  4. Verify the change: You can check the ownership of the file using:

    ls -l example.txt

This will display the current owner and group of the file. If you want to change ownership recursively for a directory and all its contents, add the -R option:

sudo chown -R owner:group /path/to/directory

0 Comments

no data
Be the first to share your comment!