The following introduces some commonly used commands in test work. Those not specifically marked are those under Linux and Mac systems.
View the process occupying the port
Linux
aaron@ubuntu:~$ lsof -i :8085 | grep LISTEN
___server 69080 aaron 11u IPv6 0x5624b7cdebdb6b7b 0t0 TCP *:8085 (LISTEN)
Windows
C:>netstat -aon | findstr :80 | findstr LISTENING
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 2588
TCP [::]:80 [::]:0 LISTENING 2588
Kill process
Linux
aaron@ubuntu:~$ kill -9 69080
Windows
PS C:\WINDOWS\system32> taskkill /F /PID 8152
SUCCESS: The process with PID 8152 has been terminated.
If you have insufficient permissions under Windows, you can right-click the Start button to start PowerShell in administrator mode.
View process by name
aaron@ubuntu:~$ ps -ef | grep nginx | grep -v grep
root 21471 1 0 2020 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 21472 21471 0 2020 ? 00:07:55 nginx: worker process
Use grep -v grep to filter out the viewing process itself.
Command line pipeline
aaron@ubuntu:~$ ps -ef | grep nginx | grep -v grep | awk '{print $2}' | xargs kill -9
The pipeline is used here to kill the process named nginx.
- Use the pipe character to pass the standard output of the command as the standard input of the next command;
- Use awk to print the second column of the captured line, and the columns are divided by spaces or Tab symbols;
- Use xargs to convert the standard output of the previous command into the parameters of the next command.
Running service in the background
aaron@ubuntu:~$ nohup appium -p %d --default-capabilities '{"udid":"sn"}' > appium.log 2>&1 &
The background runs appium service for the mobile phone with the designated serial number sn.
Modify file
Find the line starting with "Version" in the zd.conf file and replace it with "Version = 2.0".
Linux
sed -i "s/Version.*/Version = 2.0/" zd.conf
Mac
gsed -i "s/Version.*/Version = 2.0/" zd.conf
Copy directory to remote
scp -r bin/utl-server/0.8/linux/utl-server 139.224.8.129:~
View files in real time
aaron@ubuntu:~$ tail -f jmeter.log
2021-04-25 15:11:51,723 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2021-04-25 15:11:51,723 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser
2021-04-25 15:11:51,723 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser
2021-04-25 15:11:51,789 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2021-04-25 15:11:51,789 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1
2021-04-25 15:11:51,789 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
View running services
aaron@ngtesting-lab:~$ systemctl | grep apparmor
apparmor.service. loaded active exited LSB: AppArmor initialization
Check service status
aaron@ubuntu:~$ service apparmor status
● apparmor.service - LSB: AppArmor initialization
Loaded: loaded (/etc/init.d/apparmor; bad; vendor preset: enabled)
Active: active (exited) since Fri 2021-05-28 09:42:26 CST; 18s ago
Docs: man:systemd-sysv-generator(8)
Process: 19969 ExecStop=/etc/init.d/apparmor stop (code=exited, status=0/SUCCESS)
Process: 20185 ExecStart=/etc/init.d/apparmor start (code=exited, status=0/SUCCESS)
Restart service
aaron@ubuntu:~$ sudo service apparmor restart
View memory status
aaron@ubuntu:~$ free -h
total used free shared buff/cache available
Mem: 7.8G 2.3G 931M 40M 4.6G 5.2G
Swap: 0B 0B 0B
Check disk status
aaron@ubuntu:~/ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 799M 3.4M 795M 1% /run
/dev/vda1 40G 33G 4.8G 88% /
tmpfs 3.9G 8.0K 3.9G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 799M 0 799M 0% /run/user/1000
Monitor system status
aaron@ubuntu:~$ top
top - 09:29:37 up 378 days, 16:35, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 146 total, 1 running, 145 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.2 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 8174708 total, 953320 free, 2365784 used, 4855604 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 5426472 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14459 root 10 -10 135204 17124 14024 S 0.7 0.2 2:52.83 AliYunDun
956 root 20 0 2428132 92556 16208 S 0.3 1.1 2690:07 java
3217 999 20 0 90232 7264 3296 S 0.3 0.1 308:04.26 redis-server
Under Windows, right-click on the taskbar and select Task Manager .
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。