Forrest logo
tool overview
On this page you find all important commands for the CLI tool chown. If the command you are looking for is missing please ask our AI.

chown

The chown command line tool is used in Linux and Unix systems to change the ownership of files and directories. The word "chown" stands for "change owner". By default, only the superuser or the file's current owner can change ownership.

Here's the basic syntax of the chown command:

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

The options that are commonly used with chown include:

  • -R (or --recursive): Recursively changes the ownership of directories and their contents.
  • -v (or --verbose): Outputs a message for each file processed, showing the changes made.
  • -c (or --changes): Shows only the files whose ownership has been changed.

The OWNER argument represents the new owner's username or UID (user identifier). Optionally, you can also specify a GROUP name or GID (group identifier) to change the group ownership as well. If you omit the GROUP argument, the file's group ownership remains unchanged.

Examples:

  1. Change the owner of a file:

    chown newuser myfile.txt

    This command changes the file myfile.txt to be owned by the user newuser.

  2. Change the owner and group of a directory and its contents recursively:

    chown -R user:group mydir/

    This command changes the ownership of the directory mydir/ and all its subdirectories and files to the specified user and group.

Be cautious when using the chown command, as changing the ownership of system files may result in system instability or security issues.

List of commands for chown:

  • chown:tldr:0afb3 chown: Recursively change the owner of a directory and its contents.
    $ chown -R ${user} ${path-to-directory}
    try on your machine
    explain this command
  • chown:tldr:1214d chown: Change the owner user of a file/directory.
    $ chown ${user} ${filename_or_directory}
    try on your machine
    explain this command
  • chown:tldr:1e60f chown: Change the owner of a symbolic link.
    $ chown -h ${user} ${path-to-symlink}
    try on your machine
    explain this command
  • chown:tldr:493cc chown: Change the owner of a file/directory to match a reference file.
    $ chown --reference=${path-to-reference_file} ${filename_or_directory}
    try on your machine
    explain this command
  • chown:tldr:56be8 chown: Change the owner user and group of a file/directory.
    $ chown ${user}:${group} ${filename_or_directory}
    try on your machine
    explain this command
tool overview