Linux command: Chown

Source: Internet
Author: User

Chown Introduction to Commands:

command to change the owner of a file (this command can only be used by an administrator)

1 . Command format:

Chown USERNAME Files

2 . Command function:

Commands to change the owner of a folder

3 . Command parameters:

- R: Modify the owner (recursive modification) of the directory and its internal files and subdirectories

--reference=/path/to/somefile file,... Change the owner of the file to

/path/to/somefile files as many files are separated by commas.

Eg: #chown--reference=/etc/passwd/etc/test/100.sh,/etc/test/200.sh

The owner of the 100.sh and 200.sh two files is changed to be the same as the/etc/passwd file owner.

4 . Command instance:

1, Chown Donggen 100.sh to change the owner of the 100.sh file to Donggen

[Email protected] test]# ls-l

-rwxr-xr-x. 1 root root 273 September 19:49 100.sh

[Email protected] test]# chown Donggen 100.sh

[Email protected] test]# ls-l

-rwxr-xr-x. 1 donggen Root 273 September 19:49 100.sh This file is a master changed to Donggen

2, Chown donggen/test1 the Test1 group's owner changed to Donggen

[Email protected]/]# Ls-ld/test1

Drwxr-xr-x. 2 root root 4096 October 16:36/test1 owner is root before change

[Email protected]/]# chown Donggen/test1

[Email protected]/]# Ls-ld/test1

Drwxr-xr-x. 2 Donggen root 4096 October 16:36/test1 The owner of this directory has changed to Donggen

3, Chown-r donggen/test the test group and its internal subdirectories and the owner of the file are modified

[Email protected]/]# ls-ld/test

Drwxr-xr-x. 2 root root 4096 October 09:21/test change before owner is root

[Email protected]/]# ls-l/test

-rwxr-xr-x. 1 root root 273 September 19:49 100.sh change before owner is root

-rwxr-xr-x. 1 root root 252 September 18:58 hadoop.sh change before owner is root

-rwxr-xr-x. 1 root root 455 August 18:42 myar.sh change before owner is root

[Email protected]/]# chown-r donggen/test

[Email protected]/]# ls-ld/test

Drwxr-xr-x. 2 Donggen root 4096 October 09:21/test Test directory owner changed to Donggen

[Email protected]/]# ls-l/test

-rwxr-xr-x. 1 donggen Root 273 September 19:49 100.sh Test Directory The owner of the file is also changed to Donggen

-rwxr-xr-x. 1 donggen Root 252 September 18:58 hadoop.sh Test Directory The owner of the file is also changed to Donggen

-rwxr-xr-x. 1 donggen Root 455 August 18:42 myar.sh Test Directory The owner of the file is also changed to Donggen


This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1861547

Linux command: Chown

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.