"Go" How to change File Ownership & Groups in Linux

Source: Internet
Author: User
Tags readable file permissions

The issue of file permissions under Linux has not been very clear. (See Rookie Tutorial: http://www.runoob.com/linux/linux-file-attr-permission.html)

Like above, the default this link file permissions rwx rwx rwx that is the owner of the file permissions rwx (4-2-1), the owner of the group's permissions rwx, other users (all users outside the group) permissions rwx.

Linux file owner and owner group

for a file, it has a a specific owner , which is the user who has ownership of the file.

At the same time, in a Linux system, users are categorized by group , and one user belongs to one or more groups .

Users other than the file owner can be divided into the same group of users and other users as the file owner .

Therefore, the Linux system sets different file access rights by file owner, file owner, and other users.

In the above example, the bin file is a directory file, both the master and the group are root, the owner has a readable, writable, executable permission, and the owner of the same group of other users have readable and executable permissions; Other users also have readable and executable permissions.

-----------------------------------------------------------------------------------

Original: http://www.hostingadvice.com/how-to/change-file-ownershipgroups-linux/

File ownership and groups for files is fundamental to the Linux operating system. Every file in Linux are managed by a specific user and a specific group.

Figure out who owns the File and then use either ChownOr chgrp

Display ownership and group information using the following command:

12 ls -l file.txt -rw-RW -r-- 1 root www< Span class= "Crayon-o" >-data 0 feb 25 15:51 file.txt

This file was owned by the root user and belongs to the Www-data group.

Changing the Ownership of a File Using Chown

You can change the ownership of a specific file using the chown command. For security purposes only, the root user or members of the Sudo group may transfer ownership of a file.

To change the ownership of a file:

1234 chown Robert file.txt ls -l file.txt -rw-RW -r-- 1 robert www< Span class= "Crayon-o" >-data 0 feb 25 15:51 file.txt

The file file.txt is now owned by Robert. By default, chown follows symbolic links and changes the owner of the file pointed to by the symbolic link. If you wish-to-ownership of all files inside a directory, you can use the -r option.

1 Chown -R user directory/

Changing the Group Ownership of a File Using chgrp

All users on the system belong to at least one group. You can find out which groups your belong to using the following command:

1 Groups username

You can then change the group ownership of a specific file using the chgrp command:

1234 chgrp webdev file.txt ls -l file.txt -RW-rw-R-- 1 Robert WebDev 0 Feb 25 file:. txt

The file file.txt now belongs to the WebDev group.

Changing Both the Owner and the Group Using Chown

You can change both the owner and group of a file using just the chown command.

1234 chown Tito:editors file.txt ls -l file.txt -RW-rw-R-- 1 Tito editors 0 Feb 25 file:. txt

The file file.txt is now owned by Tito and belongs to the editors group.

Go to change File Ownership & Groups in Linux

Related Article

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.