Chown Command in Linux

Follow us

Chown Command in Linux

The chown command in Linux is used to change the ownership of files and directories. It allows you to modify the user and group ownership of a specific file or directory. The basic syntax of the chown command is as follows:


Here's a breakdown of the components:

  • [OPTIONS] : Optional flags that modify the behavior of the command.

  • [USER] : The new owner username.

  • [:GROUP] : Optional group name or ID to assign ownership to a specific group. If not provided, the group ownership remains unchanged.

  • FILE : The file or directory whose ownership needs to be changed.

Some commonly used options with chown are:

  • -R : Recursively change ownership of files and directories within a directory.

  • -v : Display a verbose output that shows the changes made.

  • -c : Similar to -v, but only displays output when a change is made.

  • -h : If the target is a symbolic link, change the ownership of the link itself instead of the file it points to.

Here are a few examples of how the chown command can be used:

# Change the ownership of a file to a specific user
chown user1 file.txt

# Change the ownership of a directory and its contents recursively
chown -R user2:group2 directory/

# Change only the group ownership of a file
chown :group3 file.txt

# Change ownership of a symbolic link itself
chown -h user4 link

It's important to note that the chown command usually requires root or superuser privileges to change ownership of files or directories that you don't own. Therefore, you might need to use sudo before the chown command to run it with elevated privileges.

Link Live Streaming Real Madrid vs Union Berlin
Jadwal Pertandingan Indonesia U23 vs Turkmenistan Malam Ini: Link Streaming
How to Start XAMPP in Ubuntu Using the Command Line
Linux Copy File Command
How to scan QR code on iPhone from email
© 2023 MyPurTech