Back to the command reference

chown

FilesFundamentals In simulator In real Linux

Change file owner and group

Name: chown = change owner

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

chown changes a file's owner, and with user:group its group too. For security, ordinary users can't give files away, so it usually needs sudo. -R works recursively.

Syntax

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

Common options

user:groupSet owner and group together
-R / --recursiveOperate recursively
-h / --no-dereferenceChange the symbolic link itself, not what it points to
-v / --verbosePrint a line for every file processed
-c / --changesPrint only the files that actually changed
--from OWNER:GROUPChange only files now owned by OWNER:GROUP
--reference FILEUse FILE’s owner and group

Examples

  • $ sudo chown alice report.txt

    Give the file to alice

    Explain
  • $ sudo chown -R www-data:www-data /var/www

    Recursively change a web root owner

    Explain

Related