Common linux commands,
View help:
Man command
Exit help: q
Directory and file operation commands
Command to switch the directory:
Switch the cd app to the app directory
Ca... switch to the previous directory
Cd/switch to the system root directory
Cd ~ Switch user main directory
Cd-switch to the previous directory
Create and delete directories:
Mkdir create directory
Rmdir Delete directory
Display the file list in the directory:
Ls displays the name of the visible file (and directory)
Ls-a displays the names of all files, including hidden files ("." in front of the file indicates the hidden price)
Ls-l: ll (**)
Ll-h friendly display
Q: exit the file to view
Browse files
Cat app. xml displays all content in the app. xml file.
More and less display two commands by PAGE
Tail-100 app. xml: view the content of the last 100 lines of the app. xml file (**)
Tail-f app. xml dynamic Log Viewing
Ctrl + c to end viewing
File Operations (create, copy, delete, modify, and move)
Touch file name creates a file (blank file)
Cp a.txt B .txt copy a.txt as a B .txt File
Cp a.txt ../copy the.txt file to the previous directory
Rm a.txt Delete the.txt File
Rm-f a.txt is deleted directly without inquiry.
Rm-r a.txt recursive Deletion
Rm-rf a.txt does not ask for Recursive deletion (use with caution)
Rm file name delete file
Mv a.txt ../move the.txt file to the previous directory
Mv a.txt B .txt rename a.txt to B .txt
Permission Control
Common files: including text files, data files, and executable binary program files.
Directory file: in Linux, a directory is considered as a special file, which is used to form a tree structure of the file system.
Device File: in Linux, every device is regarded as a file.
List displayed through ll
Directory files starting with d
Starting with-is a common file
File Permission: 9 letters, 3 letters, 3 groups
The first group represents the permissions of the current user.
The second group represents the group permissions.
The third group represents the permissions of other users.
R: read 4
W: Write 2
X: Execution 1
Chmod permission to change files or directories.
Chmod 755 a.txt
Chmod u = rwx, g = rx, o = rx a.txt
Chmod 000 a.txt/
★Chmod 777 a.txt
User Management
Add User
Useradd Username: by default, a directory is created for a user in the home directory.
Passwd User name: Press enter to enter the password
Useradd username-d/home/directory: create a user and
Delete
Userdel Username: only deletes the user but does not delete the home directory.
Userdel-r username: delete a user's home directory
Modify
Usermod-s/bin/ksh-d/home/z-g developer sam
This command changes the logon Shell of user sam to ksh, the main directory to/home/z, and the user group to developer.
Switch user
Ssh-l username-p 22 host address
Su-User Name
Group Management
Add
Groupadd group name
Useradd username-g group name
Delete
Groupdel group name
Note: if there are users in the group, they cannot be deleted.
Modify
# Groupmod-g 10000-n group3 group2
This command changes the ID of group group2 to 10000 and the group name to group3.
Process Management
The status of a running ps Process
Ps-ef view all processes
★Ps-ef | grep ssh searches for a process
Kill to kill a process
Kill 2868 kill the 2868 Process
★Kill-9 2868 force kill Process
Disk Management
Df: list the total disk usage of the file system
Du: Check disk space usage
Fdisk: used for disk partitioning
Network Management
Ifconfig: view all network settings
Ifconfig Nic name down: Disable Nic
Ifconfig Nic name up: Enable Nic
Ping: same as in window
Cancel with ctrl + c
Netstat: view the network port.
Netstat-an | grep 3306 query port 3306 usage
Other common commands
Grep: Find the matching string (★)
Grep string
Pwd: displays the current working directory
Wget: Download Materials
Wget resource path
Firewall commands
Systemctl status firewalld. service View Firewall status
Systemctl disable firewalld. service disable enabling firewall upon startup
Systemctl start firewalld. service Enable Firewall
Systemctl stop firewalld. service disable Firewall