Linux creates user operations and sets permissions

 1 First create a new user

sudo useradd -m username 

-m: Automatically create the user's login directory

2 Create user

sudo passwd username

3.Set password

4.1. When adding a user, set the group the user belongs to.

groupaddusernamegroup1  _

 4.2 Reset the user’s group

usermod -g [group name] [user name]

4.Set user file permissions

chmod

Character operation
uses [user ID][operator][permission content] as the grammatical rules, as follows:
User ID:
u: Indicates the user to whom the file belongs (user)
g: Indicates the user group (group)
o: Indicates other users (other )
a: Indicates all of the above three (all);
Operator:
+: Add permission
-: Delete permission
=: Set permission to
Permission content:
r: Read permission
w: Write permission
x: Execute permission
A few examples: ( The possible administrator rights are omitted here. If necessary, add sudo before the following command)
'chmod u+w aFile: Add write permission to aFile to the user to whom aFile
belongs chmod gw aFile: Make the user group to which aFile belongs have access to aFile Cannot write
chmod a+rwx aFile: Add read, write, and execute permissions to aFile for all users
chmod u=rw: Set the permissions of aFile's user on aFile to read and write (there is no x here, so it is equivalent to rw-, even if The user you belonged to had execution permissions before the modification, and the execution permissions will be deleted after executing this command).


 

Guess you like

Origin blog.csdn.net/cppyydswh/article/details/131441322