chown

>Usage

chownis a command used to change the ownership of a file or directory. It allows you to assign a new user and/or group to a file, which is useful when transferring files or managing file access.

>Synopsis

chown [option] [option]

>Options

-username

-username: Specifies both the new user (owner) and group for the file.

Example 1:

Dots

-zsh

> chown john:admin file.txt


-R

-R (recursive): Applies the ownership change to the specified directory and all files and subdirectories within it.

Example 2:

Dots

-zsh

chown -R john:admin /folder


-h

-h (no dereference): Changes the ownership of symbolic links (symlinks), rather than the file they point to.

Example 3:

Dots

-zsh

> chown -h john:admin symlink.txt


--reference

--reference: Changes the ownership of the file to match another file's ownership.

Example 4:

Dots

-zsh

> chown --reference=otherfile.txt file.txt


-v

-v (verbose): Provides output for each file that has its ownership changed.

Example 5:

Dots

-zsh

> Chown -v john:admin file.txt


>Quiz

Progress: Question ? out of ?

Question Title

Page written by FIlippo Orlando