Linux Learning Note Four

Source: Internet
Author: User

Unit Five

########################## 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 # # users All information

- G # # # User IDs for all groups (including universities,Linux groups, 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 !


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 # # # Toggles 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/bi N

# #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. /etc/skel/.*# # User's basic information configuration

③ User Commands

A. New User:useradd-d Root - G Main group - G Append group list (comma separated) user name

B. Reset password:passwd user name

c. Modify User:usermod-d Root - G Main group - G Append group list (comma separated) user name ———— The-G of the command moves the user from the original additional group and can use the-a parameter indicates 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 ———— if uid is not specified Automatic generation of the number

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 # # # Specify uid for user

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

- G # # # Specifies additional groups, and groups also exist

- C # # User Description

- D # # # Specify user plus directory

- S # # # Specify the shellThe user uses,shell type See /etc/shells

Userdel - R # # # Delete users

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

Groupdel # # # Delete Group

passwd # # # change user password

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


################## 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.


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


&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

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.