Linux User, Group Operations Command, and file permissions modification

Source: Internet
Author: User

Linux User Management

Linux is a multi-user login operating system, multi-user sharing of resources on the host, but also have their own user space, for storing their own files. Virtually all of their files are in the same physical disk or even in the same logical partition or directory.

View Current User Login who

Create user

The root user has high rights, such as adding new users. Under Root, use the command Sueradd to add the user.

User groups: In Linux, each user has a attribution, the user group is a set of users, they share some resources and permissions. You can know which user group the user belongs to through groups user. You can also view the user groups by viewing the/etc/group file. Cat/etc/group

adduserAnd useraddThe difference?

A: Useradd only create users, created by using passwd Lilei to set your password
AddUser will create a user, create a directory, create a password (prompting you to set), do this series of operations, in fact Useradd,userdel, these belong to a class of operations, it is more like a command, the execution is finished on the return. And AddUser is more like a program that requires you to enter and determine the series of operations

Useradd, Usermod and Userdel

Useradd

A) –u: Specifies the user's UID---------------useradd-u 1024x768 Username
b) –g: Specify the group to which the user belongs---------------useradd-g Groups Username
c) –d: Specify the user's home directory---------------useradd-d/home/*** Username
d) –c: Specify user's note information---------------useradd-c Description Username
E) –s: Specifies the user's shell---------------useradd-s/bin/bash Username

Usermod:

A) –u: Modify the UID of the user---------------Usermod-u uid Username
b) –g: Modify the user's GID---------------usermod-g gid Username
c) –G: Add a user to the specified group---------------usermod-g Groupname Username
d) –d: Modify the user's home directory---------------usermod-d/home/*** Username
e) –c: Modify user's Notes information---------------usermod-c Description Username
f) –s: Modify the shell---------------Usermod-s used by the user/bin/bash/username

Group Management

Groupadd, Groupmod and Groupdel

–g: Specify the GID for the group
For example, a new command for a group named Boydogs is added to the system: Groupadd boydogs
–G: Modifying a group's GID
–n: Modify the name of the group
For example: Modify the police group's GID to 521 command:
Groupmod–g 521 Police
For example, the command to rename a group boydogs to Daddogs:
Groupmod–n Daddogs Boydogs
Example: Delete the daddogs Group command: Groupdel daddogs

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

Linux file Permissions

To view file permissions, we use Ls-l to view the permissions of the file.

All files in Linux

R:read Read permissions, you can use commands such as cat filename to read the contents of a file.

W:write Write permission, which means you can edit and modify files, such as echo "Echo 12345" >> filename.

X: Execute permissions, usually referred to as binary or script files that can be run.

A directory has both read and Execute permissions to open and view internal files, and to have write permission to allow other files to be created, because the catalog file actually holds information such as a list of files in that directory.

Modify file Permissions

1. Binary number Modification

RWX represents three Bits, 111 is full, and 000 is all-off. such as chmod 777 Test.txt

2. Add and subtract assignment operations

U:user G:group o:other such as chmod u+rwx g+rwx o+rwx test.txt

Change the owner of a file with Chown
Chown: Genus Group File
Chown: Genus Group File
Chown Master File
A) For example, the command that modifies the file file1 is root: chown root file1

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

Manipulating files to create a new user

1. Add user name information under/etc/passwd

2. Add password information (copy) under/etc/shadow

3. Add group information under/etc/group

4. Add the group password information under/etc/gshadow

5. Create home directory/home/alex

6. Copy the home directory corresponding file (Cp-r/etc/skel/. [!.] */home/alex)

7. Modify the directory owner and the owning group Chown-r Alex.alex/home/alex

8. Create a mailbox file Touch/var/spool/mail/alex

9. Modify the mailbox file to belong to Chown-r Alex.mail/var/spool/mail/alex

10. Change the user Alex Password, switch the virtual device login.

Attached: passwd stored in the user login information, divided into seven paragraphs in turn:

User name: Password placeholder: User id: Group ID: Profile: Home directory:/bin/bash

Linux User, Group Operations Command, and file permissions modification

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.