V: Linux Owner

Source: Internet
Author: User

It is the true nature of the struggle to be accused of doing good deeds and still persist. --Balzac


the content of this lecture: file owner, group, other group
Each user in Linux must belong to a group and cannot be independent of the group. In Linux , each file has the concept of owner, group, and other groups.


I. Owner of the file

Typically, the creator of the file, who created the file, becomes the owner of the file naturally.

You can see the owner of the file by using the [Ls-ahl] command

You can also modify the owner of the file by using [chown username file name ]

Second, the group

When a user creates a file, the group in which the file is located is the group that the user is in.

Use the [Ls-ahl] command to see all groups of files

You can modify the group where the file is located by using [chgrp Group name file name ] .


Third, other groups

Except for the owner of the file and the user in the group, the other users of the system are other groups of files.


Let's take a look at an example and create three users to put in two groups

1, add a group can only operate under root Groupadd group name

Groupadd Policemangroupadd Tufei

How to view an existing group: Vi/etc/group Cat/etc/group (cat can only see can not write, vi can see change)


2. Create user and add to specified group

USERADD-G Group name User name

Useradd-g policeman Jinuseradd-g policeman Danuseradd-g policeman Lin
Change the user's group

Usermod-g Tufei Lin

View all user information: VI/etc/passwd cat/etc/passwd


Note:/bin/bash the shell parser that the user is using


-|rw-|r--|r--1 Dan policeman one Dec 9 09:32 Mytest1.java

The first character represents the file (-), directory (d), link (l)

1 represents 1If it is a file, and if it is a folder, it displays a total of several files under this folder.


The permissions are divided into three categories:Rreadable  with4Express;Wcan be written  with2Express;xexecutable with1represents
command to change permissions: chmod 755 dan : Give dan permission rwxr-xr-x (refers to folder access)

chmod 755 Mytest1.java gives mytest1.java permission rwxr-xr-x (refers to a file)



Change owner (chown) and user group (chgrp) commands:

chown xiaoming ABC: Change the owner of ABC to xiaoming

chgrp Root ABC: Change the group that the ABC belongs to is root

chown root./abc: Change ABC the owner of this directory is root

chown–r root./ABC: Change the ABC directory and the owner of all files and directories below it is root



V: Linux Owner

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.