Management of Linux accounts and permissions

Source: Internet
Author: User

Learn about common account profiles

Learn to manage user accounts and group accounts

Learn to set permissions for a directory or file

Learn to set the attribution of a directory or file

    • User account file/etc/passwd: Save the user name, host directory, login shall and other basic information

Each row corresponds to one user's account record

(All users have access to the contents of the passwd file, but only the root user can change it)

650) this.width=650; "Width=" 666 "height=" "title=" image "style=" padding-top:0px;padding-right:0px;padding-left:0 Px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src=" Http://s3.51cto.com/wyfs02/M01/6C/6E/wKiom1VJaq2RuCgAAABS2_2dtAk615.jpg "border=" 0 "/>

    • User account file/etc/shadow: Save the user's password, account validity and other information

(Each line of the file contains nine configuration fields with a colon: split)

Each row corresponds to a user's password record

650) this.width=650; "Width=" 643 "height=" Bayi "title=" image "style=" padding-top:0px;padding-right:0px;padding-left:0 Px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/6C/6E/wKiom1VJaq3y3SvjAACJjobheSA263.jpg "border=" 0 "/>

    • Add user account

Useradd command: useradd [options] User name

Command options:

-u: Specify UID tag number for user

-D: Specify the host directory, default to/home/user name

-e: Specify the expiration time of the account

-G: Specify the user's base group name (or UID number)

-G: Specify the user's additional group name (or GID)

-M: Cannot establish and initialize host directory for user

-S: Specify the user's login shell

Example: Specifying User uid1000

650) this.width=650; "Width=" 471 "height=" 234 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M01/6C/6E/wKiom1VJaq3Q1RmQAADstdkIKhg651.jpg" border= "0"/>

Example: Modifying the validity period of an existing user

650) this.width=650; "Width=" 469 "height=" title= "image" style= "Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6E/wKiom1VJaq3BvPFqAACjRtgCNLY945.jpg" border= "0"/>

Example: Adding a user VPN Specifies the host directory/ftpusers

650) this.width=650; "width=" 470 "height=" 124 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6E/wKiom1VJaq3A8Y0jAABoO7nQ5pA323.jpg" border= "0"/>

Example: Specify Mike's basic group as Mike and join to the Ftpuser group, specifying the host directory as/ftpuser/mike, forbid Mike by logging on locally to the server

Prerequisites: Host directory, basic group, additional group

650) this.width=650; "Width=" 485 "height=" 232 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6A/wKioL1VJbCDCM79SAAC6iQG3iaY334.jpg" border= "0"/>

    • Initial profile of user account

File Source: When creating a new user account, copy from the/etc/skel directory

Primary User profiles:

~/bash_profile: Executed every time the user logs on

~/BASHRC: Execute every time you enter a new bash environment

~/bash_logout: Executed every time the user logs on

Example: View ~/BASHRC

(You can also edit it with the VIM command)

650) this.width=650; "Width=" 455 "height=" 282 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6E/wKiom1VJarCDPfqRAADHcQeSJrM720.jpg" border= "0"/>

    • Set/change user password passwd [options] User name

-D: Clear the user password so that it can be logged in without a password

-L: Lock user account

-S: View the user's status (whether bound)

-U: Unlock user account

Note: Modify the password of the current account when using the passwd command without specifying a user name

Example: Set user Geng Empty password login and view user status

650) this.width=650; "Width=" 397 "height=" 142 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6E/wKiom1VJarCgXamPAACPN94tWfk075.jpg" border= "0"/>

    • Modify user's account properties Usermod [options] User name

-L: Change the login name of the user account

-L: Lock user account

-U: Unlock user account

-u: Specify UID tag number for user

-D: Specify the host directory, default to/home/user name

-e: Specify the expiration time of the account

-G: Specify the user's base group name (or UID number)

-G: Specify the user's additional group name (or GID)

-S: Specify the user's login shell

Example: change user VPN user name to Vpner

650) this.width=650; "Width=" 422 "height=" 126 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6E/wKiom1VJarGg_0EcAACqJ99owls887.jpg" border= "0"/>

    • Delete user account Userdel [options] User name

-R: Indicates that the user's host directory is deleted

Example: Delete the user Mike and the host directory

650) this.width=650; "Width=" 425 "height=" 153 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M01/6C/6E/wKiom1VJarKxzT6VAAClT-DCzcs905.jpg" border= "0"/>

    • Group account Files

/etc/group: basic information for saving group accounts

/etc/gshadow: Save user's password information

Example: Viewing group information for a user Geng

650) this.width=650; "Width=" 415 "height=" 203 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6A/wKioL1VJbCOQoocJAACDF7hy4qY332.jpg" border= "0"/>

    • Add group account Groupadd [-G GID] group account

Example: Adding group and group accounts market

650) this.width=650; "Width=" 459 "height=" 131 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6E/wKiom1VJarOyxNh8AABy1NIgJIg912.jpg" border= "0"/>

    • Delete groups/Add group members GROUPWD [options] group account name

Groupwd use: Add/Remove group members, set the group account password rarely used

-A: Adding a user to a group

-D: Remove a user from a group

-M: Defines a list of group members, separated by commas

Example: Adding a user Geng to a xteam group

650) this.width=650; "Width=" 460 "height=" 198 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6A/wKioL1VJbCXCLHKeAACaSp7y6KM814.jpg" border= "0"/>

Example: Defining a user Geng,vpner in a group market group

650) this.width=650; "Width=" 477 "height=" 162 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6A/wKioL1VJbCaDaR_AAACExOuXgN4056.jpg" border= "0"/>

    • Delete Group account Groupdel group account

Example: Deleting a group account Xteam

Note: First delete the user, in deleting the group account, no group account is very dangerous

650) this.width=650; "Width=" 456 "height=" 211 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M01/6C/6A/wKioL1VJbCaREJzsAACq5ygwnHo061.jpg" border= "0"/>

    • Enquiry Account Information

ID: View user identity

Groups: Check the group to which the user belongs

Finger: Check the user account details

Example: Use the above command to view user Vpner information

650) this.width=650; "Width=" 465 "height=" 227 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6A/wKioL1VJbCeQi7i4AAC36I8lm6c955.jpg" border= "0"/>

    • Users, W, who commands: Querying user information that has landed on the host

650) this.width=650; "width=" 499 "height=" 225 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6A/wKioL1VJbCjQ3W_0AAC219kIvWA458.jpg" border= "0"/>

    • Permissions and attribution of files/directories

Access rights:

Read r: Allow viewing of file contents, display directory list

Write W: Allow new, move, delete files or directories in the directory

Executable: Allow to run programs, switch directories

650) this.width=650; "Width=" 577 "height=" "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M01/6C/6A/wKioL1VJbCniS60gAACklr0pRxU777.jpg" border= "0"/>

Example: Viewing Permissions for Install

650) this.width=650; "Width=" 582 "height=" "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6A/wKioL1VJbCmid8JAAABsMSekk-A713.jpg" border= "0"/>

Start with a normal file, beginning with D to indicate a directory or folder, with L as the link, starting with a C to indicate the drive

File default permissions 755, directory default 644

    • Set permissions for files and access to directories chmod

Format 1:chomod [Ugoa] [+,-, =] [rwx] File or directory

Ugoa, respectively, belong to the owner, group, other users, all users. +,-, = Add, remove, set permissions, respectively.

Format 2:chmod nnn file or directory

nnn = 3-bit 8 binary number

Common command Options-r: Recursively Modify permissions for all sub-options in the specified directory

Example: the right to add write to the Catalog install group

650) this.width=650; "Width=" 507 "height=" 155 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6E/wKiom1VJarjzEYRtAACeU718Hkc319.jpg" border= "0"/>

650) this.width=650; "Width=" 509 "height=" "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6E/wKiom1VJarnjyP1gAAB7yWaIL08546.jpg" border= "0"/>

    • Set the attribution of files and directories Chown

Chown Master file or directory

Chown: Represents a group file or directory

Chown: A group of files or directories

Common command Options-r: Recursively Modify permissions for all sub-options in the specified directory

Example: Modify the document owner, belong to the group

650) this.width=650; "Width=" 506 "height=" 255 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M01/6C/6E/wKiom1VJarqB1OZQAAEIMhRR-EA699.jpg" border= "0"/>

650) this.width=650; "width=" 505 "height=" 188 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M02/6C/6A/wKioL1VJbCygaFBwAAC1cCnC4JM271.jpg" border= "0"/>

Example: Modify the home folder and file directory permissions to 775

650) this.width=650; "Width=" 514 "height=" 365 "title=" image "style=" Padding-top:0px;padding-right:0px;padding-left : 0px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;background-image:none; "alt=" image "src = "Http://s3.51cto.com/wyfs02/M00/6C/6A/wKioL1VJbC6BWAxbAAGiiOGVKic875.jpg" border= "0"/>

Management of Linux accounts and permissions

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.