Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Create a new user in Linux and grant relevant permissions to the specified directory

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1 create a user and specify the user's root path and password useradd-d / home/mydir-m username

Users created in this way can log in using ssh, but only read-only permissions can browse and download some files that cannot be written or modified.

It is recommended that you gain permission for the specified path by adding the user to a group.

2 set password passwd username3 user authorization chown-R username: username / home/ mydirchmod 755 / home/mydir4 to join the user to the group

Add a user to a user group and try not to use it directly (unless you really belong to only one group):

Usermod-G groupA username

Doing so will cause you to leave other user groups and just be a member of this user group groupA.

You should use the-an option:

Usermod-a-G groupA username5 View groups to which a user belongs use the command groups username6 to delete a user or user group

Userdel username

Groupdel groupname

7 View user information

Cat / etc/passwd can view a list of all users

W can view the list of currently active users

Cat / etc/group View user groups

Groups to view the group members of the currently logged in user

Groups gliethttp views the group in which the gliethttp user belongs and the members of the group

Whoami to view the current login user name

A concise layout command

Cat / etc/passwd | grep-v nologin | grep-v halt | grep-v shutdown | awk-F ":"'{print $1 "|" $3 "|" $4}'| more

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report