Linux Learning Note Four

Source: Internet
Author: User

Unit V

########################## User Action command #################

(i) use of ID

ID user name # # View user Information

Id-u # # # user uid(userid)

-G # # user gid(initial group ID, only one)

-A # # user All information

-G # # User ID for all groups (including university,Linux Group, etc.)

-un # # # User name

-gn # # # User Initial group name

-gn # # # users all group names

Execute vim/etc/login.dafs, the user's uid default is !

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/88/45/wKioL1ftGHfRKs59AACqPLWqBz8616.png-wh_500x0-wm_3 -wmp_4-s_3622819962.png "title=" image 1.png "alt=" Wkiol1ftghfrks59aacqplwqbz8616.png-wh_50 "/>

The operating conditions are:

[Email protected] desktop]$ echo $PATH

/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin

[[email protected] desktop]$ which LS

Alias ls= ' ls--color=auto '

/usr/bin/ls

(ii) Switch User's environment

Echo $PATH # # # View the user environment for the current user, which displays the current PATH environment variable, which consists of a series of colon-delimited directory names.

Echo $USER # # # Displays information about the current user

su-username### Switching the environment used by the current user

# #kiosk原本的环境

[Kiosk Echo $PATH

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/kiosk/.local/bin:/home/kiosk/bin

# #root原本的环境

[Root Echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

# #root用su-kiosk Switch to kiosk while switching to Kiosk's own environment variable

[Root Su-kiosk

[Kiosk Echo $PATH

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/kiosk/.local/bin:/home/kiosk/bin

# #root用su Kiosk switches to kiosk, but still root path, no path to the kiosk

[Root su Kiosk

[Kiosk Echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

The difference between SU student and su-student when switching users :

1.su-student Switch User, and user's environment, add "-" environment variable also changed;

2. do not add "-" that is, su student just switch users.

(iii) actions for users and Groups

1. User

① User Type

A. administrator Root: A user with all permissions,the value ofuid is 0

B. Normal User: Normally created user,uid is ~60000

C. system users: To ensure that the system operation of users, generally do not provide password login system,the UID is 1~499

② user-related files

A./etc/passwd## user Information file

stores the user's basic properties, from which all users of Linux can be viewed . The format is:

"User name: Password: User ID: Owner group ID:user description (e.g. name, age, phone, etc.): User root: User programming environment ( Shell used ) "

Each user group has one primary group (private group), one or more additional groups.

B./etc/shadow## user authentication information

Some strategies for storing user passwords in the form of:

"User name: Password: the date of the most recent password change: The number of days the password cannot be changed: Warning period before password change: Password expiration Grace time: Account expiration Date: Reserved"

C./home/username## user home directory

D. basic information configuration for/etc/skel/.*## users

③ User Commands

A. new User:useradd-d root- G Primary Group - G additional group list (comma separated) user name

B. Reset Password:passwd user name

C. Modify User:usermod-d root- G Primary Group - G additional group list (comma separated) user name ———— the command- G will move the user from the original additional group, you can use the- a parameter to indicate that the new mode

D. deleting a User:userdel-r Delete a user name together with the root directory

E. View all users:cat/etc/passwd

F. viewing individual user details:ID user name

G. view all currently logged-in users:WHHO

2. User Groups

The user group is the user's container, and the user can inherit permissions from the user group.

① User Group Type

A. common user groups: can join multiple users

B. System user group: Generally add some system users

C. Private user group: When a user is created, a user group with the same name will be created for that user if no user group is indicated. A private user group is actually a common user group.

② user group related files

A./etc/group## user group information

Basic information about the storage group. The format is;

"group name: Group Password: group ID: User list"

B./etc/gshadow

similar to the shadow of the user group

③ User Group Commands

A. new group:groupadd-g uid number group name ———— automatically generated if the uid number is not specified

Groupadd-g 888 Test(Specify uid as 888)

Groupadd hehe(uid not specified )

B. modify group:gruopmod-n new group name ———— can be used to group names

Groupmod-n Jack Jaak

C. Delete Group:groupdel Group name ———— cannot be deleted if there are users in the group

D. View all Groups + view users within a group:cat/etc/gruop

E. viewing the user's group information:ID user name

Output:

Uid=0 (Root) gid=0 (root) groups=0 (root)

UID is the primary group,gruops is the additional group

F. adding users to a group:gpasswd-a user name Group name

G. removing a user from a group:gpasswd-d user name Group name

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

(iv) detailed operation of the user

useradd### New User

-u### The UID of the specified user

-g### Specify user initial group, this group must exist

-g### Specify additional groups, the same group must exist

-c### User Description

-d### Specify user plus directory

-s### Specify the shell that the user uses ,shell type See /etc/shells

userdel-r#### Deleting a user

groupadd-g### New Group,-g indicates the ID of the specified group

groupdel### Deleting a group

passwd#### Changing user passwords

"Example"useradd-u 1016(existing group number) - G 1016(existing group number) test(user name)

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/88/45/wKioL1ftGJ-gdgv1AAEsa5ZA_aM324.png-wh_500x0-wm_3 -wmp_4-s_2998973060.png "title=" image 2.png "alt=" Wkiol1ftgj-gdgv1aaesa5za_am324.png-wh_50 "/>

################## First, listen passwd . ###########

Watch-n1 Tail-n 3/etc/passwd

1.

Useradd Add test User

Useradd Test

When a process is in use and cannot delete test :

Kill + The process number

And then again:

Userdel-r Test

So that we can remove it successfully.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/88/49/wKiom1ftGK2A0nZFAAC2MTREFQk092.png-wh_500x0-wm_3 -wmp_4-s_3524330545.png "title=" image 3.png "alt=" Wkiom1ftgk2a0nzfaac2mtrefqk092.png-wh_50 "/>

2.

User uid and gid can be specified at the same time

Useradd-u 888-g 888 Test

3.

Add user instructions (to delete test before it can be established)

Useradd-c "Test User" test

4.

Specify User home Directory

useradd-d/mnt/test Test

5.

Specify the shell type used by the user

Useradd test-s/bin/tcsh

6.

See the types of shells

&nbsp123&nbsp123

&nbsp123

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/88/45/wKioL1ftGLqxGpG2AACwMc2OJ08198.png-wh_500x0-wm_3 -wmp_4-s_414170767.png "title=" image 4.png "alt=" Wkiol1ftglqxgpg2aacwmc2oj08198.png-wh_50 "/>

&nbsp123

&nbsp123

&nbsp123&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

&nbsp123

Linux Learning Note Four

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.