B03 - 003, users, user groups

Disclaimer: This article is a blogger original article, shall not be reproduced without permission. https://blog.csdn.net/weixin_42464054/article/details/91410461

0, this chapter outlines the learning catalog - users, user groups

Beginner consuming: 1h

Note: CSDN end of the phone does not support chapter jumps within the chain, but the chain is available, also requested a better experience on the PC side.

First, the basic cognitive
  1.1 superuser (learning)
  1.2 average user (work)

Second, the user
    2.1 Creating user.
    2.2 password.
    2.3 View validation.
    2.4 switch user.
    2.5 Exit user.
    2.6 Delete user.
    2.7 Remove validation.
    2.8 useradd parameter list.
    2.9 root and home.

Third, the user group
  3.1 to create a group.
  3.2 View validation.
  3.3 Create a temporary user.
  3.4 add users to groups.
  3.5 Check how many users group.
  3.6 To view the user belongs to which group.
  3.7 remove users from the group.
  3.8 delete user groups.

Fourth, the temporary root privileges: sudo
    4.1 for ordinary users to set permissions.




Beverage giant comfort zone Akzo  ||  ♂ ♀ tired feel no love





First, the basic cognitive

  1.1 to superuser (learning)

When learning to use the root user, what can be done is to learn.

  1.2 to ordinary users (working)

Time work, access control, to prevent trouble or deliberate misuse brought.



Strong challenge yourself, challenge others weak.

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


Second, the user

  2.1 to create a user.

useradd -d /home/xiaozhang xiaozhang

  2.2 to set a password.

passwd xiaozhang
123456

  2.3 to view verification.

ls /home
cat /etc/passwd

  2.4 to switch user.

su xiaozhang

  2.5 to exit the user.

exit

  2.6 to delete users.

userdel -r xiaozhang

  2.7 to delete verification.

ls /home
cat /etc/passwd

  2.8 to useradd parameter list.

-c comment Comment for the user to set the account caption
...
-d home directory specified home directory used instead of default / home / username of
...
-m If the home directory does not exist, create it. -r and -m combine to create a home directory for system accounts
...
-M do not create the home directory
...
-e DATE designated account expiration date. The date format is MM / DD / YY
...
-f Days overdue account permanently suspended a few days. Then immediately be suspended, and if it is -1, then turn off this feature - if designated as
...
-g to specify a user group to which the user will join a user group, the user group must exist (main group)
...
list of user groups specified -G list of user groups while adding users and groups separated by commas
...
-n Do not create private user group for the user
...
-s using the login shell specified user shell, which defaults to / bin / bash
...
-r create a user ID is less than 500 the system accounts, default does not create a home directory corresponding
...
-u user ID manually specify a new user ID value, this value must be unique and greater than 499
...
-p password Specifies the password for the new user. Password corresponding to the password here is a value obtained by MD5 encrypted password obtained, false true original password, so in practical applications, this parameter options use less, usually alone passwd command to set the password for the user.

  2.9 ~ root and home directory.

/root
/home/xiaozhang


Strong challenge yourself, challenge others weak.

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




Third, the user group

  3.1 to create a group.

groupadd shanghai
groupadd beijing

  3.2 to view verification.

cat /etc/group

  3.3 to create a temporary user.

useradd -d /home/xiaozhang xiaozhang
useradd -d /home/xiaorong xiaorong
useradd -d /home/xiaokai xiaokai

passwd xiaozhang
passwd xiaorong
passwd xiaokai

  3.4 to add users to groups.

usermod -a -G shanghai xiaozhang
usermod -a -G shanghai xiaorong

usermod -a -G beijing xiaokai

  3.5 to see how many users group.

cat /etc/group
cat /etc/group | grep shanghai

  3.6 to view the user belongs to which group.

groups root

groups xiaozhang
groups xiaokai

When you create xiaohei user, it will automatically create a user group xiaohei the same name, and the user xiaohei on the user group xiaohei, and later, we again xiaohei users into user groups in shanghai, therefore, belongs to both the user xiaohei group.

  3.7 to remove a user from a group.

gpasswd -d xiaorong shanghai

  3.8 to delete user groups.

groupdel beijing

gpasswd -d xiaokai beijing


Strong challenge yourself, challenge others weak.

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




Fourth, the temporary root privileges: sudo

  4.1 to set permissions for ordinary users.

    4.1.1 Switching root user.
su root
    4.1.2. Open the / etc / sudoers.
visudo
    4.1.3 Display line numbers.
:set nu
    4.1.4 cancel the line number.
:set nonu
    4.1.5 Modify line 92.
xiaozhang ALL=(ALL) ALL
xiaorong ALL=(ALL) ALL
xiaokai ALL=(ALL) ALL
    4.1.6. Successfully verified.
su xiaozhang
cd /home

# 失败
touch abc.txt
# 成功
sudo touch abc.txt


Strong challenge yourself, challenge others weak.

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



^ At this point, users, user groups completed.


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


※ worldly temptations so great that the firm always moved.

If a binary tree has 1026 nodes, the depth of its possibilities How many? (Assuming that only the depth of the root node is 1)


A、2
B、1017
C、1014
D、1015
E、1016

E
alt



Strong challenge yourself, challenge others weak.

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


Note: CSDN end of the phone does not support chapter jumps within the chain, but the chain is available, also requested a better experience on the PC side.

I know my weakness, I know what you are picky, but I just I do not like fireworks, thank you for pointing, creating a piece of me :)!



Strong challenge yourself, challenge others weak.


Guess you like

Origin blog.csdn.net/weixin_42464054/article/details/91410461