What does the 'chown' command do?

QuestionsQuestions8 SkillsProPermissions of FilesAug, 06 2025
0610

The chown command in Linux is used to change the ownership of a file or directory. It allows you to modify both the user and group ownership of a file.

Syntax

The basic syntax of the chown command is:

chown [OPTION]... [OWNER][:[GROUP]] FILE...

Key Components

  • OWNER: The new owner of the file.
  • GROUP: The new group associated with the file (optional).
  • FILE: The file or directory whose ownership you want to change.

Example Usage

  1. To change the owner of a file named example.txt to user1, you would use:

    sudo chown user1 example.txt
  2. To change both the owner to user1 and the group to group1, you would use:

    sudo chown user1:group1 example.txt

Important Note

  • The chown command typically requires superuser (root) privileges, so you may need to use sudo before the command to execute it successfully.

0 Comments

no data
Be the first to share your comment!