As an excellent PHP engineer, have you mastered all these Linux commands?
Preface
This article contains common Linux commands. There is a little trick here. Basically all commands are followed by --h to show how to use them. Therefore, there is no need to memorize them by rote. If you know their meaning, you will understand their shape. (Recommended: Linux Video Tutorial)
is classified as follows:
● File & Directory Operations (16)
● View File & Content Processing ( 18 items)
● File compression & decompression (3 items)
● Information display (11 items)
● File search (4 items)
●●Process management (11 items)
●User management (7 items)
●Network operations (11 items)
●Disk & file system (7 items)
● System permissions (3)
● Shut down and restart (5)
● Others (6)
File & directory operations (16) )
ls
● ls -a View all files, including hidden files
● ls -l Abbreviation ll, view detailed information
● ls -h Display the file size in an easy-to-read format
cd
● cd ../ Return to the upper directory
● cd ~ Go to home directory
●cd - Return to the last directory
cp
●cp -r Copy the directory and files under the directory
find
● Find / -name 'target' Query the file named target under the root directory
mkdir
●mkdir -p /tmp/test Create directory recursively
mv
●mv -f source destination Force
pwd
● pwd displays the current path
#rm
● rm -rf / Forcefully delete files in the root directory and directory, that’s us What is usually called deleting the database and running away
touch
● Touch target creates the target file and changes the file timestamp if the file exists
tree
● The tree function is to display the contents of the directory in a tree structure
basename
● basename /tmp/1 display File name
dirname
● dirname /tmp/1 Display path
chattr
● chattr i /tmp/1 Add i attribute to prevent the file from being modified
lsattr
● lsattr /tmp/1 View the extended attributes of the file
file
● file /tmp/1 Display file type
md5
● md5 /tmp/1 Display File MD5 value
View file & content processing (18)
cat
● cat -n display line number
● cat file1 file2 Open files 1 and 2
more
● more file1 Display page by page
less
●●less file1 is also displayed page by page, in the opposite direction to more
head
●head -n file displays the file header n lines
tail
tail -n file displays the last n lines of the file
tailf file displays the last 10 lines of the file in real time, often used to track log information
cut
● Who|cut -b 1-3,5 Outputs 1 to 3 bytes and the 5th byte of each line
●who|cut -c -3 Output 1 to 3 characters of each line
● Who|cut -c 3- Output the 3rd character of each line to the end of the line
●who|cut -d ' ' -f 1 Use space as the delimiter to output the first domain
split
Split -b 10k date.file Split the file into multiples of 10k Subfile
● Split -b 10k date.file split_file Specify the subfile prefix as split_file
#paste
●psate file1 file2 file3 will 3 Merge files by columns
sort
Sort -n Sort by numerical size
Sort -r Sort in reverse order
● sort -t specifies the delimiter
● sort -u ignores the same lines
uniq
● uniq -c displays the number of occurrences, Only adjacent ones are considered duplicates
● uniq -d only displays duplicate lines
●unqi -u only displays non-duplicate lines
wc
● wc -l displays the number of columns
diff
##● diff file1 file2 Compare the differences between two filesrev
● rev file Reverse output file contentgrep
●grep 'target' file Filter the output file to contain target Lines●grep -v 'target' file Filters the lines that do not contain target in the output file●grep -c 'target' file Filters the number of lines that contain target in the output file ●grep -i 'target' file Ignore case ●egrep '[1-9]|a' file Filter output lines matched by regular expressions●Seq 10 | grep "5" -A 3 Displays the 3 lines after matching a certain result ● seq 10 | grep "5" -B 3 Displays the 3 lines before matching a certain result ● seq 10 | grep "5" -C 3 Displays the first three lines and the last three lines matching a certain result#join
● join file1 file2 Join the two files , connect lines with the same content in the specified fieldtr
● cat text | tr '\t' ' ' Replace tab characters with spaces
vim
Three modes:
● Edit mode (command mode) ● Input mode ● Last line modeMode conversion
Edit-> Inputi: 在当前光标所在字符的前面,转为输入模式; a: 在当前光标所在字符的后面,转为输入模式; o: 在当前光标所在行的下方,新建一行,并转为输入模式; I:在当前光标所在行的行首,转换为输入模式 A:在当前光标所在行的行尾,转换为输入模式 O:在当前光标所在行的上方,新建一行,并转为输入模式;
ESC
:
ESC,ESC
Open file
vim +# :打开文件,并定位于第#行 vim +:打开文件,定位至最后一行 vim +/PATTERN : 打开文件,定位至第一次被PATTERN匹配到的行的行首
Close File
:q 退出 :wq 保存并退出 :q! 不保存并退出 :w 保存 :w! 强行保存
Move the cursor (edit mode)
- ##Move character by character
h: 左 l: 右 j: 下 k: 上 #h: 移动#个字符
Copy after login
- Move in units of words
w: 移至下一个单词的词首 e: 跳至当前或下一个单词的词尾 b: 跳至当前或前一个单词的词首 #w: 移动#个单词
Copy after login
- Jump within the line
0: 绝对行首 ^: 行首的第一个非空白字符 $: 绝对行尾
Copy after login
- Jump between lines
#G:跳转至第#行 gg: 第一行 G:最后一行
Copy after login
Ctrl+f: 向下翻一屏
Ctrl+b: 向上翻一屏
Ctrl+d: 向下翻半屏
Ctrl+u: 向上翻半屏
x: 删除光标所在处的单个字符
#x: 删除光标所在处及向后的共#个字符
dd: 删除当前光标所在行 #dd: 删除包括当前光标所在行在内的#行;
u:撤消前一次的编辑操作
#u: 直接撤消最近#次编辑操作
连续u命令可撤消此前的n次编辑操作
撤消最近一次撤消操作:Ctrl+r
/PATTERN
?PATTERN
n 下一个
N 上一个
●tar zxvf FileName.tar.gz Decompression
●tar zcvf FileName.tar.gz DirName Compression
zip
● zip -r html.zip/home/html Recursive compression
unzip● unzip test.zip -d /tmp Extract to the specified directory
Information display (11 items)
uname●uname -a Display all system information
hostname● hostname displays the host name
dmesg● dmesg displays boot information
uptime● uptime displays system running time and load
stat#● stat displays file status information
du● du -sh displays the size of all files under the path
●du -sh local displays the file size of the local directory under the path
● du -sh * Display the size of all directory files under the path
df● df -h Display the system disk space usage
top
● Top displays system resource usage in real time
#free● free -m Views the system in M units Memory
date "%Y-%m-%d" 2019-05-28
date -d "1 day ago" "% Y-% m-% d" Output yesterday's date
● Date -d "1 day" % Y% m% d Display the previous day's date
● date -d "-1 day" % Y% m% d displays the date of the next day
● Date -d "-1 month" % Y% m% d displays the date of the previous month
● date -d " 1 month" % Y% m% d displays the date of the next month
● date -d "-1 year" % Y% m% d displays the date of the previous year
● date -d "1 year" % Y% m% d displays the date of the next year
cal
● Cal calendar information
Search files (4)
which
●which pwd displays the command path
find
●find /-name 'target' Query the file named target under the root directory
whereis
● whereis php search binary command
locate
● locate target from the database (/var/ lib/mlocate/mlocate.db) Find the target file and use updatedb to update the library
Process Management (11)
jobs
● Jobs View How many commands are currently running in the background
#bg
●bg 1 Continue executing a command that is paused in the background, 1 is the job number
● (ctrl z) can suspend the program and return the job number
fg
● fg 1 Move the command in the background to the foreground to continue running, 1 is the job number
kill
● Kill process number kills the process
●kill -9 process number kills the process
● Killall
● Killall php Kill the process by process name
●killall -9 php Kill the process by process name
pkill
●Usage is the same as above
crontab
●crontab -l View scheduled tasks
●crontab -e Edit scheduled tasks
●crontab -l -u user1 View user1's scheduled tasks, only root has permission
●crontab -e -u user1 Edit user1's scheduled tasks, only root has permission
ps
●ps -ef View the process, display UID, PPIP, C and STIME, and the environment variable field used by each program
●ps -axu View all processes, and Display the process number and process id tree belonging to the user
pstree
●pstree -p Display the process number and process id tree of all current processes
●pstree -a Display all processes All detailed information tree
nohup
● nohup command & does not hang up the program when exiting the account, it is still running in the background
pgrep
● pgrep -l httpd Find http-related process numbers
User management (7)
useradd
● useradd boy -u 888 Create a new user account and set the ID
● useradd –g sales jack –G company,employees
● -g: Join the main group -G: Join Secondary group
usermod
Usermod -G staff newuser2 Add newuser2 to group staff
Usermod -l newuser1 newuser Modify newuser The username is newuser1
● usermod -L newuser1 locks the account newuser1
● usermod -U newuser1 unlocks newuser1
userdel
● Userdel -f user1 Forcefully delete the user
● Userdel -r user1 When deleting the user, delete all files related to the user
groupadd
●groupadd -g 1000 group1 Create a new group and set the group ID to join the system
passwd
●passwd user1 Modify user1 password
●●passwd -l user1 Lock password
●passwd -d user1 Delete password
su
●su root Switch identity
sudo
● sudo command Running command as administrator
Network operations (11)
telnet
● Telnet 127.0.0.1 Log in to the remote host
ssh
● ssh root@127.0.0.1 -p22 Log in to the remote host
scp
● scp local_file remote_username@remote_ip:remote_folder Copy local to remote
●scp remote_username@remote_ip:remote_folder local_file Remote copy to local
wget
●wget url Download a file
●wget --limit -rate=300k url speed limit download
● wget -c url resume breakpoint
●wget -b url background download
ping
● ping www.baidu.com -c 2 End after receiving two packets
route
● route displays the current route
ifconfig
●ifconfig View, configure, enable or disable network interfaces
ifup
ifup eth0 Open eth0 Network card
●ifdown
●ifdown eth0 Close eth0 network card
netstat
●netstat -at List all tcp ports
●netstat -au lists all udp ports
●netstat -l displays only listening ports
ss
● ss - t -a displays all tcp links
● ss -l displays sockets in listening state
Disk & file system (7)
mount
● mount /dev/hda1 /mnt Mount /dev/hda1 to the /mnt directory
● umount
● umount -v /mnt/mymount / Unmount/mnt/mymount/
fsck
● fsck -y /dev/hda2 Check and repair the Linux file system
dumpe2fs
● dumpe2fs /dev/hda1 View file system information
dump
● dump -0u -f /tmp/homeback.bak /home
Back up all the contents of the /home directory to the /tmp/homeback.bak file, the backup level is 0 and record relevant information in /etc/dumpdates
fdisk
● fdisk /dev/sdb
Enter m to list the executable commands
Enter p to list the current partition status of the disk
Enter d Then select the partition and delete the existing partition
Enter print to check the partition status and confirm that the partition has been deleted
Enter n to create a new disk partition
Enter w to finally operate the partition Save
mkfs
●mkfs -t ext3 /dev/sda6 Format the sda6 partition into ext3 format
System permissions (3)
chmod
●Chmod 777 file1 Modify file1 file permissions to 777
●Chmod u x,g w file1 Set file1 to be executable by yourself, team members Writable permissions
chown
●Chown -R root /usr/meng Modifies the directory /usr/meng and all files and subdirectories below it Change the file owner to root
chgrp
●chgrp -R mengxin /usr/meng Change the user group of all files in /usr/meng and its subdirectories Shut down and restart for mengxin
(5)
shutdown
● Shutdown -h now Shut down immediately
●shutdown 5 " System will shutdown after 5 minutes" Specifies the shutdown after 5 minutes and sends a warning message to the logged in user
halt
● Halt -p Turn off the power after shutting down the system
● Halt -d shuts down the system without leaving a record
poweroff
●poweroff -f forcefully shuts down the operating system
logout
●logout exits the currently logged-in Shell
exit
● exit exits the currently logged-in Shell
Others (6)
echo
● echo 'hello' prints strings and variables
●printf 'hell0' Formatted output string
rpm
●rpm -ivh your-package.rpm Install rpm package
● rpm -Uvh your-package.rpm Upgrade rpm package
● rpm -e package Uninstall
● rpm -qa List all installed packages
● rpm -ql package name rpm where to install the files in the package
yum
● yum install php install php
● yum remove php Uninstall php
clear
●clear Clear the screen
history
●history 10 The 10 most recently used historical commands
Extended reading:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status