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

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

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 have only read-only permissions to browse and download some files but cannot write or modify them.

It is recommended to obtain permissions for the specified path by adding the user to a group.

2 Set a password

passwd username

3 User Authorization

chown -R username: username /home/ mydir
chmod 755 /home/mydir

4 Add users to the group

Add a user to a user group. Try not to use it directly (unless it really belongs to only one group):

usermod -G groupA username

Doing this will remove you from the other groups and make you a member of groupA only.

Should be used with -a option:

usermod -a -G groupA username

To view the groups to which a user belongs, use the command

groups username

Summarize

The above is what I introduced to you about creating a new user in Linux and granting relevant permissions to the specified directory. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • How to disable root remote login and add new users in Linux
  • Detailed explanation of how to set SFTP service user directory permissions in Linux system
  • A detailed introduction to Linux file and directory permissions
  • The meaning of file permissions and directory permissions in Linux and the significance of permissions to file directories

<<:  Complete steps to install MySQL 8.0.x on Linux

>>:  DOM operation implementation in react

Recommend

Detailed explanation of adding dotted lines to Vue element tree controls

Table of contents 1. Achieve results 2. Implement...

JavaScript canvas to achieve meteor effects

This article shares the specific code for JavaScr...

Implementation and usage scenarios of JS anti-shake throttling function

Table of contents 1. What is Function Anti-shake?...

Common symbols in Unicode

Unicode is a character encoding scheme developed ...

Example of MySQL auto-increment ID exhaustion

Display Definition ID When the auto-increment ID ...

Tips for using DIV container fixed height in IE6 and IE7

There are many differences between IE6 and IE7 in ...

MySQL series 9 MySQL query cache and index

Table of contents Tutorial Series 1. MySQL Archit...

The solution of html2canvas that pictures cannot be captured normally

question First, let me talk about the problem I e...

Detailed explanation of CSS3 elastic expansion box

use Flexible boxes play a vital role in front-end...

Tips for making web table frames

<br />Tips for making web table frames. ----...

Vue uses GraphVis to develop an infinitely expanded relationship graph

1. Go to the GraphVis official website to downloa...

XHTML Getting Started Tutorial: Simple Web Page Creation

Create your first web page in one minute: Let'...