The Chown of Linux

Source: Internet
Author: User

Command function:

Chown the owner of the specified file to the specified user or group, the user can be either a user name or a user ID; a group can be a group name or a group ID; a file is a space-separated list of files to change permissions, and wildcard characters are supported. System administrators often use the Chown command to give users permission to use a file after copying it to another user's directory.

Command format:
--reference=rfile FILE ...
Command parameters:-c,--changes only outputs the information of the changed file-f,--silent,--quiet when Chown cannot change the file mode, the user who does not notify the file--help output help information. -r,--recursive can recursively traverse subdirectories, change the changes to all files and subdirectories in the directory--reference=filename refer to the permissions of filename to set permissions-v,--verbose regardless of whether the modification is successful, output the information for each file-Hrelated to symbolic links, to be continued ..
-Hrelated to symbolic links, to be continued ...
-Lrelated to symbolic links, to be continued ...
-Prelated to symbolic links, to be continued ...--version output version information. --reference=< directory or File > set to have the same permissions as the specified directory or file
--version Display version Information Command instance:

Assume that the file information in the directory is:

[Email protected]:~/test$ lltotal ADRWXRWXR-X3Vbird Vbird4096September8  -: the./drwxr-xr-x4Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Vbird Vbird0September8  -: thea.txt-rw-rw-r--1Vbird Vbird0September8  -: theB.TXTDRWXRWXR-X2Vbird Vbird4096September8  -: -dir/

1. Change the owner and group. Change the owner of the a.txt to root and the group to the root group.

[Email protected]:~/test$ su//The root user is required to modify file permissionsPassword:[email protected]:/home/vbird/test# lltotal ADRWXRWXR-X3Vbird Vbird4096September8  -: the./drwxr-xr-x4Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Vbird Vbird0September8  -: thea.txt-rw-rw-r--1Vbird Vbird0September8  -: theB.TXTDRWXRWXR-X2Vbird Vbird4096September8  -: -dir/[email protected]:/home/vbird/test# chown root:root a.txt[email protected]:/home/vbird/test# lltotal ADRWXRWXR-X3Vbird Vbird4096September8  -: the./drwxr-xr-x4Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Root root0September8  -: thea.txt-rw-rw-r--1Vbird Vbird0September8  -: theB.TXTDRWXRWXR-X2Vbird Vbird4096September8  -: -dir/[email protected]:/home/vbird/test# exitexit[email protected]:~/test$

2. Change the owner and group of all files in the specified directory and its subdirectories. Change the dir directory and all the file owners under dir/to root and the group to the root group.

[Email protected]:~/test$ lltotal ADRWXRWXR-X3Vbird Vbird4096September8  -: the./drwxr-xr-x4Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Vbird Vbird0September8  -: thea.txt-rw-rw-r--1Vbird Vbird0September8  -: theB.TXTDRWXRWXR-X2Vbird Vbird4096September8  -: -dir/[email protected]:~/test$ ll Dirtotal8DRWXRWXR-X2Vbird Vbird4096September8  -: -./DRWXRWXR-X3Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Vbird Vbird0September8  -: -C.txt-rw-rw-r--1Vbird Vbird0September8  -: -D.txt[email protected]:~/test$ supassword:[email protected]:/home/vbird/test# Chown Root:root-R dir[email protected]:/home/vbird/test# lltotal ADRWXRWXR-X3Vbird Vbird4096September8  -: the./drwxr-xr-x4Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Vbird Vbird0September8  -: thea.txt-rw-rw-r--1Vbird Vbird0September8  -: theB.TXTDRWXRWXR-X2Root root4096September8  -: -dir/[email protected]:/home/vbird/test# ll Dirtotal8DRWXRWXR-X2Root root4096September8  -: -./DRWXRWXR-X3Vbird Vbird4096September8  -: the.. /-rw-rw-r--1Root root0September8  -: -C.txt-rw-rw-r--1Root root0September8  -: -D.txt[email protected]:/home/vbird/test# exitexit[email protected]:/home/vbird/test#

The Chown of Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.