Linux User and User Group management commands

Source: Internet
Author: User
Tags chmod dba readable

1. Useradd

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

Useradd User Name

If you enter the following command:

Useradd NewUser

The system will create a new user NewUser, and the user's home directory is/home/newuser.

The Useradd command has more parameters, and the common combination is:

Useradd username G Group name-G Group name-D home directory name-p password

Where: g Specifies the primary group of the user

-g Specifies the user's secondary group

-D Specify the user's home directory

-p Specifies the password for this 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 primary group is Oinstall, the secondary group is the Dba,home directory is/home/oracle, the password is ora123.

2. Userdel

The Userdel command deletes 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:

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 in the following usage:

Groupdel Group Name

5. passwd

For system security reasons, every user in the Linux system, in addition to their user name, has a corresponding user password, and the user can change his or her password at any time with the passwd command. The general format for this command is:

passwd

After entering this command, the password and password are confirmed by the system prompts, then the user's password can be modified.

In addition, a superuser can modify the password of another user, and the command is as follows:

passwd User Name

6. Su

The SU command is important in that it allows an average user to have Superuser or other user privileges, or to allow Superuser to do something as a regular user. A normal user must have the password of a superuser or another 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

7. chmod

The chmod command is important to change the access rights of a file or directory. There are two ways to use this command: One is the text-setting method that contains the letter and operator expressions, and the other is the numeric setting that contains the 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, the operating object who can be any of the following letters or their combination:

U represents user, the owner of a file or directory

G represents the same group of users, that is, all users who have the same group ID as the file owner

O indicates other (others) users

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

2. The operation symbol can be:

+ Add a permission

-Cancel a permission

= give the given permission and cancel all other permissions

3 mode indicates that the commonly used parameters of permissions are

R readable

W can write

X executable

Example:

1, the File script permissions set to executable. The order 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 document is the main readable, writable, executable, and file owners of the same group of users can read, other users are not readable. The order is as follows:

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

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 owners and groups of a file or directory. For example, the root user copies one of his files to Oracle, and in order for the user Oracle to access the file, the root user should set the owner of the file to Oracle, otherwise the user Oracle will not be able to access the file. The basic usage of chown is:

chown [User: Group] File

Example:

Chown ORACLE:DBA Text

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

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.