(16) User management
1) View online users who
2) View Current user WhoAmI
3) Add user Useradd or adduser-m automatically create directory-D Create directory
Useradd-m Liu Auto Add home directory/home/liu
4) Create a password for the user passwd
If the password is changed, enter passwd directly
passwd Liu changes the password of Liu
5) Delete User Userdel
Userdel User Name
Userdel-r User name Delete user at the same time delete user's home directory
6) Viewing user groups
Cat/etc/group viewing the current user group
or Groupmod (Tab key three times)
7) Add user group Groupadd add
8) Delete user group Groupdel
9) View the user's group groups
Groups user Name
10) Modify the group where the user is located usermod
USERMOD-G User group user name-G modified Default user group
Add multiple user groups
Usermod-a-G user group user name-G Add user group to add other groups with-a
11) Create a normal user to add sudo permissions
sudo usermod-a-G ADM user name
sudo usermod-a-g sudo user name
17) Modify file Permissions chmod: Letter method, Digital method
chmod u/g/o/a +/-/= rwx file
U: The owner of the file
g; user groups
O: Others
A:all Everyone
+: Increase Permissions
-: Insurance rights
=: Set curve
Digital method: R:4 w:2 x:1-:0 (0 does not have any permissions)
chmod 777 File1
x corresponding folder (directory) execution for accessible or forbidden access
Modify file Owner: Chown
Chown user name file or directory
Modify file belongs to group: CHGRP
CHGRP user group name file or directory name
Basic use of the 4 VI editor
VI Editor Three modes: General mode, edit mode, command mode
(1) Open, new, save file
VI File name: Open or New file
: WD Save and exit
: q! force does not save exit
; Q exit
: Save
(2) Enter edit mode
I insert character in light label
I Insert beginning of line
A inserts a character after the cursor
A: Insert End of line
O Enter characters at the beginning of the next line
O Enter characters at the beginning of the previous line
(3) Cursor Movement (normal mode)
In normal mode, move the cursor with four keys
H---> Left
J---> Down
K---> On
L---> Right
H: Move to the top of the current screen
M: Move to the middle of the current screen
L: Move to the bottom of the current screen
G: Move to the specified line, NG
W: Move backward one word at a time
B: Move forward one word at a time
{: Moves by Segment, move up
}: Move down by segment, Move Down
CTRL d: Flip down half screen
CTRL u: Flip up half screen
Ctrl F: Flip one screen down
CTRL B: Turn up one screen
GG: Cursor moves to the beginning of the file
G: Cursor moves to end of file
(4) Delete command
x: Delete a character after the cursor
X: Delete a character before the cursor, equivalent to BACKSPACE
DD: Delete the line of the cursor, n DD Delete the specified number of rows D: Delete all contents of the line after the cursor, including the character of the cursor
D0: Delete all contents of the line before the cursor, not including the character of the cursor
DW: Delete the word at the beginning of the cursor, containing the character of the cursor
(5) Cancellation order
U: Step-by-step undo
Ctrl-r: Anti-revocation
(6) Repeat command
. (one point): Repeats the last action command
(7) Text line movement
>>: Text line moves right
<<: Text line shift left
(8) Copy and paste
YY: Copy the current line, n yy copy n rows
P: Place a new line at the cursor location and paste
(9) Visual mode
V: Move by character, select text
V: Move by row, select text visual mode can be used with d,y,>>,<< to achieve the deletion of the text block, copy, left and right to move
(10) Replace operation
R: Replace the current character
R: Replaces the character after the current line cursor
(11) Find command
/:str Find
N: Next
N: Previous
(12) Replace command
:%s/abc/123/g: Replace ABC all to 123
:%S/ABC/123/GC need to be confirmed when replacing
s replace G global C acknowledgment
2 Linux basic Commands review 2