User management related commands for Linux applications

Source: Internet
Author: User
Tags readable

1. Useradd

The Useradd command can create a new user account with the most basic usage of:

Useradd User Name

If you enter the following command:

Useradd NewUser

The system will create a new user, NewUser, who has a home directory of/home/newuser.

The parameters of the Useradd command are many, and the commonly used combinations are:

Useradd User name-G Group name-G group name-D Home directory name-p password

Where:-g Specifies the user's first group

-g Specifies the user's secondary group

-d Specifies the user's home directory

-P Specify the password for the user

If you enter the following command:

Useradd oracle–g oinstall–g dba–d/home/oracle–p ora123

The system will create a user Oracle Oracle user's first group is Oinstall, the secondary group is the Dba,home directory is/home/oracle, and the password is ora123.

2. Userdel

The Userdel command is used to delete an existing account with the following usage:

Userdel User Name

3. Groupadd

The Groupadd command can create a new user group with the most basic usage of:

Groupadd Group Name

If you enter the following command:

Groupadd NewGroup

The system will create a new user group, NewGroup.

4. Groupdel

The Groupdel command is used to delete an existing user group with the following usage:

Groupdel Group Name

5. passwd

For system security reasons, each user in the Linux system has its own user password in addition to its user name, and the user can change his or her password with the passwd command at any time. The general format of the command is:

passwd

After entering this command, follow the system prompts to enter the password and password confirmation, you can complete the user password modification.

In addition, the superuser can also modify the password of other users, the command is as follows:

passwd User Name

6. Su

The SU command is important because it allows a normal user to have access to a superuser or other user, or to allow a superuser to do something as a normal user. Ordinary users must have a password for the superuser or other user when using this command. To leave the current user's identity, you can type the exit command, and the general form of the SU command is:

su– User name (user Switching)

#su-Normal User/* switch from root to normal user, whether with "-" option indicates whether to switch users to the user home path at the same time */

$SU-*/* switch from normal user to root user and need to provide root password * *

7. chmod

The chmod command is very important for changing the access rights of a file or directory. There are two ways to use this command: One is a text-setting method that contains a letter and an operator expression, and the other is a digital setting method that contains numbers.

Because the digital setting method is not very intuitive, this article does not introduce. The use of the text setting method is as follows:

chmod [who] [+ |-| =] [mode] File name

The meanings of the options in the command are:

1. Who can be any of the following letters or their combinations:

U means the user, that is, the owner of the file or directory

G represents the same group user, i.e. all users with the same group ID as the file owner

O indicates other (others) users

A represents all users (all), which is the system default value.

2, the operation symbol can be:

+ Add a permission

-Cancel a permission

= Give a given permission and cancel all other permissions

3 mode means that the parameters commonly used for permissions are

R readable

W Writable

X executable

Example:

1. Set the permissions of the file script to executable. The command is as follows:

chmod =rx Text

After successful execution, the results of viewing the file properties with the Ls-l Script command are as follows:

-r-xr-xr-x 1 user group 0 Feb 09:42 Script

2, the file text permissions set to: The file belongs to the main readable, writable, executable, and the file belongs to the same group of users can read, other users unreadable. The command is as follows:

chmod u=rwx,g=r,o= Text (note that there are no spaces after o=)

After successful execution, the results of viewing the file properties with the Ls–l Text command are as follows:

-rwxr-–1 User Group 0 Feb 09:42 text

8. Chown

Chown is used to change the owner and the group of a file or directory, and this command is also common. For example, the root user copies one of his files to the user Oracle, in order for the user Oracle to be able to access the file, the root user should set the owner of this file as Oracle, otherwise the user Oracle cannot access the file. The basic usage of chown is:

chown [User: Group] File

Example:

Chown ORACLE:DBA Text

This command changes the owner and owner groups of the text file to Oracle and DBA respectively.

User management related commands for Linux applications

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.