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

The normal method of MySQL deadlock check processing

Normally, when a deadlock occurs, the connection ...

How to use javascript to do simple algorithms

Table of contents 1 Question 2 Methods 3 Experime...

Using CSS3 to achieve transition and animation effects

Why should we use CSS animation to replace JS ani...

win2008 server security settings deployment document (recommended)

I had been working on the project before the New ...

Docker custom network implementation

Table of contents 1. Customize the network to rea...

js dynamically implements table addition and deletion operations

This article example shares the specific code for...

Vue.set() and this.$set() usage and difference

When we use Vue for development, we may encounter...

Solutions to invalid is Null segment judgment and IFNULL() failure in MySql

MySql Null field judgment and IFNULL failure proc...

Vue axios interceptor commonly used repeated request cancellation

introduction The previous article introduced the ...

jQuery implements shopping cart function

This article example shares the specific code of ...

MySQL 5.7 Common Data Types

——Notes from "MySQL in Simple Terms (Second ...

Analysis of Facebook's Information Architecture

<br />Original: http://uicom.net/blog/?p=762...

How to build a React project with Vite

Table of contents Preface Create a Vite project R...

Detailed explanation of mysql backup and recovery

Preface: The previous articles introduced the usa...