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

Implementation steps for docker deployment of springboot and vue projects

Table of contents A. Docker deployment of springb...

Two ways to implement text stroke in CSS3 (summary)

question Recently I encountered a requirement to ...

Implementation of local migration of docker images

I've been learning Docker recently, and I oft...

Implementation steps for enabling docker remote service link on cloud centos

Here we introduce the centos server with docker i...

How to use worm replication in Mysql data table

To put it simply, MySQL worm replication is to co...

Vue+Element UI realizes the encapsulation of drop-down menu

This article example shares the specific code of ...

Example of using mycat to implement MySQL database read-write separation

What is MyCAT A completely open source large data...

How to implement insert if none and update if yes in MySql

summary In some scenarios, there may be such a re...

Problems with creating placeholders for HTML selection boxes

I'm using a placeholder in a text input and i...

Detailed explanation on how to get the IP address of a docker container

1. After entering the container cat /etc/hosts It...

Detailed explanation of upgrading Python and installing pip under Linux

Linux version upgrade: 1. First, confirm that the...

React implements dynamic pop-up window component

When we write some UI components, if we don't...