Linux under User management instructions __linux

Source: Internet
Author: User
Tags reserved unique id

W

To view logged-in users in the machine


Pkill-kill-t PTS/1

Kick off the user and need root privileges


Use of/etc/nologin files:

If you want only root can log on to the host, other accounts can not log in, you may add a file named "Nologin" in the/etc directory, as long as the file to enter a few characters, as long as the system found that the existence of the file will prevent other users from logging in.

The Useradd command (also available with adduser) is used to create a new user account with the following command format:

table 4-19 useradd commands common options

Common Phenomenon

meaning

-D

Set up a new user's login directory

-E

Sets the stop date for the new user with a date format of Mm/dd/yy

-F

The account expires several days after the permanent stop right. When the account is 0 o'clock, the right is immediately stopped. This feature is turned off when the value is-1. The preset value is-1

-G

Make new users Join groups

-G

Make new users join a new group. Each group is separated by commas "," and cannot be mixed with blank words.

-S

Specify a login shell for a new user

-U

Set the new user's ID value

After a new user is successfully created, a row of that user's information is added to the/etc/passwd file in the following format:

(User name):(password):(uid):(gid):(identity description):(home directory):(login Shell)

One of the fields is divided into 7 parts by a colon ":".

Since the UID and GID less than 500 are generally reserved by the system themselves and do not need to be marked as normal users and groups, the newly added users and groups are typically UID and GID greater than 500.

For example, use the following command:

(root@localhost root)# Useradd User1

A user named Userl will be created, and the user Management command has been introduced and no more introductions are made here.

The result of executing the USERADD command is shown in Figure 11-13. Like what:

Mkdir/home/guestdir

Useradd guest-d/home/guestdir

is to create a user, specify a directory


passwd Guest

This is an instruction to modify the guest user's password.


ID View User Details

ID Guest


Modify user Information Usermod

The Usermod command is used to modify user information, with the following command format:

# usermod(option)(user name)

Shown in the common command option 11-20.

table 4-20 usermod commands common options

Common options

Significance

-D

Update users ' new login directory

-E

Sets the stop date for the new user with a date format of Mm/dd/yy

-F

The account expires several days after the permanent stop right. When the account is 0 o'clock, the right is immediately stopped. This feature is turned off when the value is-1. The preset value is-1

-G

Update users new user join group

-G

Defines a user as a bunch of groups members. Each group uses the ".. "Separated, can not be mixed with blank words

-L

Change the name of the user when they log in, and the username will be changed to the new name.

-S

Specify new user Shell

-U

User ID value, which must be a unique ID value. The document directory used under the user directory tree will automatically change its userid, and the documents placed outside the support directory will be manually altered.

For example, the following command modifies user information:

(root@localhost root)# Usermod–d/home/user2–s/bin/bash User2

Set the user name User2 's home directory path to/home/user1, and the login shell is set to/USR/BIN/GCC.

In general, the USERMOD command modifies the user account information by referencing the part of the command instruction. However, Usermod does not allow you to change the user account name on the line, so when you use Usermod to change your account information, you must make sure that it is not executing any programs on your computer.

Modify the group to which the user belongs

USERMOD-G Group Usercode

For example:

Usermod-g Admin,lawmansoft Lawmansoft

Group separated by commas



4.6.4 New Group Groupadd

The Groupadd command is used to create a new user group with the following command format:

# groupadd(option)(user name)

Common options are:

-g:gid value. Unless you use the-o parameter, the value must be unique, not the same, and a value cannot be negative.

The GID value is preset to a minimum of less than 500 and a successive increase. 0-499 is traditionally reserved for system account usage.

-F: A new existing group account, the system will receive an error message and then end the Groupadd.

If this is the case, the group will not be added (if this is the case, the system will not be added again). You can also add the-G option, when you add a GID, then the GID is not a unique value, without the-o parameter, the built group will show the results of the establishment (adding a group as Neither–g or–o options were specified), which is R Additional options for Ed Hat Linux.

4.6.5 Delete User Userdel

The Userdel command is used to delete existing users and related documents, with the following command format:

# userdel(option) User name

Common options for Userdel commands:

-R deletes the document in the user directory. Documents from other locations will also be identified and deleted.

Userdel is not allowed to remove the user account on the line, so if you want to delete this type of user account, you must first kill the user on the system to run the program to do account deletion.

4.6.6 Delete Group Groupdel

The Groupdel command is used to delete a user group that already exists, with the following command format:

# Groupdel Group Name

Similar to Userdel, if a user in any group is on line, you cannot remove the user group, so if there is a user online in the group, it is best to remove the user and then delete the user.

4.6.7 User Switching between Su

The SU command is often used to switch between different users. Its command format is as follows:

# su(User name)

A common use of the SU command is to become a user or superuser, and if you issue an SU command with no user name, you are prompted for the root password, which you can then change to the root user. If you log on as the root user, you can use the SU command to become any user on the system without requiring a password.

For example, to switch to User2 if you log on as User1, just use the following command:

# su User2

Then you are prompted to enter the User2 password and you can switch to User2 after you enter the correct password. Once completed, you can return to User1 with the Exit command.

4.6.8 View current online users who

The WHO command is primarily used to view the current user situation online. This command is very useful. If a user wants to establish a communication with another user, such as using the Talk command, the first thing to be sure is that the user is online or the talk process cannot be established.

The system administrator, for example, wants to monitor what each logged user does at the moment and use the WHO command. Common command formats and common options for the WHO command are as follows:

# who(option)

command The WHO common command options as shown in table 4-21.

Table 4-21 commands for who common command options

Common options

Significance

-A

Show all information for all users

-M

Shows the user name running the program, and the role of "Who am I"

-Q

Displays only the number of user login accounts and login users, which takes precedence over any other option

-U

After the login user shows the last time the user has operated on the system

-H

Show Column headings

All options are optional, for example, using the command:

(root@localhose root)# Who-ah





View all users and all user groups under Linux

Groups View the members of the currently logged-on user in the group
Groups Gliethttp view the group that the Gliethttp user is in, as well as members of the group
WhoAmI view the current logon user name

/etc/ The group file contains all the user names for all groups
/etc/shadow and/etc/passwd Systems

1,/etc/group narration;

/etc/group
A
file is a user group profile that includes users and groups of users, and can show which user group or groups of users the user belongs to, because one user can belong to one or more different groups of users, and users with the same

user group have similar characteristics. For example, if we add a user to the root group, the user can browse to the root directory file, and if the root user opens the Read and write permission for a file
, all users of the root group can modify the file, if it is an executable file (such as a script), The user of the root group is also executable; the characteristics of the

User group provide great convenience for system administrators in system administration, but security is also a concern, such as having the most important content for system management under one user, and the best way to allow users to have separate user groups. Or to set the permissions of the file under the user to be completely private, and the root group should not easily include ordinary users,

2,/etc/group content specific analysis

/etc/group includes user groups (group), User group password, GID, and Users (user) included in the user group, one record per user group;

Group_name:passwd:GID:user_list

/etc/group Each record in is divided into four fields:

First field: User group name,

Second field: User group password;

Third field: GID

Fourth field: User list, split between each user; This field can be blank If the character blank represents the user name of the user group as GID.
 


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.