Linux Common Commands (Lesson 2)

edit file

vi aaa.txt Open aaa.txt file  
The esc key toggles between edit and command modes  
  
In the command mode, enter: (colon), you can enter the command  
:s/ string1/string2 Replace string1 with string2  
:wq! to save the file and exit  
:q! Force quit file editing  

check the file

cat aaa.txt View the content of the aaa.txt file  
  
head -5 aaa.txt View the contents of the first 5 lines of the aaa.txt file  
  
tail -10 aaa.txt displays the last 10 lines of the aaa.txt file

Operating users and user groups

su root switch to root user  
whoami View currently logged in users  
groups View the group to which the current user belongs  
id View current user UID and GID  
useradd adds a new user (under root)  
passwd sa Set the password of the sa user (under root)  
passwd change password  
userdel delete user (under root)  
groupadd g1 Add g1 group (under root)  
usermod -g g1 sa assign the sa user to the g1 group (under root)

Set file permissions

chmod 751 temp set 751 permissions to temp folder  
-rwxr-x--x  
111 101 001  
751  
Abbreviation for ps Process Status, used to display the status of the current process


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325401409&siteId=291194637