Linux File configuration permission

Source: Internet
Author: User

Command name: chownPermission: Root

Usage: chown [-cfhvr] [-- help] [-- version] user [: Group] File...

PS: chown can be used to change the owner of an archive. This command is only used by the system administrator (Root). Generally, users do not have the permission to change the owner of another user's archive or change the owner of their archive to another user.

Parameters:
-C or-change: similar to-V, but only the modified part is returned.
-F or-quiet or-silent: no error message is displayed.
-H or-no-dereference: only modify the file linked to the symbol, without changing any other related files.
-R or-recursive: recursive processing. All files and subdirectories under a specified directory are processed together.
-V or-verbose: displays the Command Execution Process
-Dereference: opposite to-H
-Help: displays online instructions.
-Reference = <reference file or directory>: Set the owner and group of the specified file or directory to be the same as that of the reference file or directory.
-Version: displays version information.

Examples of chown commands:

# Chown [-R] [user name] [file or directory]
# Chown [-R] [User name: group name] [file or directory]

Example 1:Change the owner of the test3.txt file to the test user.
# Ls-l test3.txt
-RW-r-1 test root 0 2009-10-23 9:59 test3.txt
# Chown test: Root test3.txt
# Ls-l test3.txt
-RW-r-1 test root 0 2009-10-23 9:59

Example 2:The new owner and new group attached to chown can be connected. One of the owners and groups can be empty. If the owner is empty, it should be ": Group". If the owner is empty, ":" is not required.

# Ls-l test3.txt
-RW-r-1 test root 0 2009-10-23 9:59 test3.txt

# Chown: Test test3.txt <= change the group of test3.txt files to test
# Ls-l test3.txt
-RW-r-1 test 0 2009-10-23 test3.txt

Example 3:Chown also provides the-R parameter, which is extremely useful for Directory change owners and groups, you can add the-R parameter to change all files in a directory to a new owner or group.
# Ls-l testdir <= view the attributes of the testdir directory
Drwxr-XR-x 2 USR root 0 2009-10-56 testdir/<= The file owner is a USR user and the owner is a root user.
# Ls-LR testdir <= view all files in the testdir directory and their attributes
Total 0
-RW-r-1 USR root 0 2009-10-23 10:38 test1.txt
-RW-r-1 USR root 0 2009-10-23 10:38 test2.txt
-RW-r-1 USR root 0 2009-10-23 10:38 test3.txt
# Chown-r test: Test testdir/<= Modify testdir and its sub-directories and all files to the new users and user groups.
# Ls-l testdir
Drwxr-XR-x 2 test 0 2009-10-23 10:38 testdir/
# Ls-LR testdir
Total 0
-RW-r-1 test 0 2009-10-23 10:38 test1.txt
-RW-r-1 test 0 2009-10-23 10:38 test2.txt
-RW-r-1 test 0 2009-10-23 10:38 test3.txt

In short, the usage here is very simple. chown Oracle/rmanbk/logs is enough... The user group has nothing to do with me.

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.