Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

Last week, our automation pipeline suddenly failed, and the error message was simply:

Connection refused

The developer said: “The service is down, go check the server.”

I logged into the test machine and resolved it with three commands:

ps -ef | grep order-service    # Check processesnetstat -tunlp | grep 8080     # Check porttail -f /var/log/order.log     # View logs

In 5 minutes, I identified: the service crashed and did not restart.

This incident made me realize: automation testing is no longer just about writing scripts; it also requires understanding the environment, troubleshooting, and collaboration.

Today, I have compiled a practical list of the 20 most commonly used Linux commands for automation test engineers, categorized by scenario, to help you navigate CI/CD, log analysis, and service validation with ease.

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ” 1. File and Directory Operations (Daily High Frequency)

1. ls β€”β€” List directory contents

ls -l          # Detailed list (permissions, size, time)ls -lh         # Human-readable file size (e.g., 2.3K)ls -lt         # Sort by modification time (latest first)βœ… Scenario: Check if the automation script is successfully deployed

2. cd / pwd β€”β€” Change and view directories

cd ~/projects/api-test   # Enter project directorypwd                      # Print current path (confirm location)

3. cat / less / head / tail β€”β€” View files

cat config.yaml          # View complete configurationless large_log.log       # View large files page by page (press q to exit)head -n 20 report.html   # View the first 20 lines of the reporttail -f app.log          # **Real-time log tracking (debugging tool!)**πŸ’‘ tail -f is the golden command for troubleshooting automation failures!

4. grep β€”β€” Text search (must-know!)

grep "ERROR" app.log                # Search for errorsgrep -i "timeout" app.log           # Ignore casegrep -n "401" app.log               # Show line numbersgrep -A 3 -B 2 "Exception" app.log  # Show matching lines with context (before and after)βœ… Scenario: Quickly locate the cause of automation failure (e.g., token expiration, connection timeout)

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ–₯️ 2. Process and Port Management (Core of Service Validation)

5. ps β€”β€” View processes

ps -ef | grep pytest        # Check if the automation process is runningps aux | grep nginx         # Check web service

6. netstat / ss β€”β€” View network connections and ports

netstat -tunlp | grep 8080      # Check if port 8080 is occupiedss -tuln                        # Faster alternative (recommended)⚠️ If command not found, install: yum install net-tools or apt install net-tools

7. kill / pkill β€”β€” Terminate processes

kill -9 12345           # Force kill process with PID 12345pkill -f "pytest"       # Kill all processes containing "pytest"βœ… Scenario: Clean up residual automation processes to avoid port conflicts

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ“¦ 3. File Transfer and Compression (Essential for Deployment)

8. scp β€”β€” Securely copy files (local ↔ server)

# Upload local script to serverscp test_order.py [email protected]:/home/qa/# Download server logs to localscp [email protected]:/var/log/app.log ./

9. tar β€”β€” Pack and unpack

tar -czvf report.tar.gz reports/    # Compress directorytar -xzvf report.tar.gz             # Unpackβœ… Scenario: Package automation reports to send to colleagues or archive

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ§ͺ 4. Network and Service Testing (Extended Interface Validation)

10. curl β€”β€” Send HTTP requests (no need for Postman)

# GET requestcurl http://api.test.com/users/1# POST JSONcurl -X POST http://api.test.com/login \     -H "Content-Type: application/json" \     -d '{"user":"test","pwd":"123"}'# With Cookiecurl -b "sessionid=abc123" http://api.test.com/profileπŸ’‘ Directly verify interfaces on the server, bypassing local network restrictions!

11. ping / telnet / nc β€”β€” Network connectivity testing

ping api.test.com               # Test domain resolution and basic connectivitytelnet db.test.com 3306         # Test if database port is reachablenc -zv redis.test.com 6379      # More modern port probing (netcat)

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ“Š 5. System Status and Resource Monitoring (Initial Performance Screening)

12. top / htop β€”β€” Real-time view of CPU/memory

top        # Built-in commandhtop       # More user-friendly (requires installation: yum install htop)βœ… Scenario: Is the server lagging during automation execution? Check resource usage!

13. df / du β€”β€” Disk space

df -h            # View disk usage (human-readable units)du -sh ./logs    # View size of logs directory⚠️ Accumulation of automation logs may lead to full disk, causing service downtime!

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ› οΈ 6. Permissions and Users (Collaboration Pitfalls)

14. chmod β€”β€” Change file permissions

chmod +x run_tests.sh    # Add execute permission to scriptchmod 644 config.yaml    # Set as read-only configuration

15. chown β€”β€” Change file owner

sudo chown qa:qa report.html   # Assign report ownership to qa user

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ”„ 7. Scheduled and Background Tasks (CI/CD Extension)

16. crontab β€”β€” Scheduled tasks

crontab -e   # Edit scheduled tasks# Run regression every day at 2 AM0 2 * * * cd /project && python -m pytest --html=report.html

17. nohup β€”β€” Run in the background (prevent disconnection)

nohup python long_run_test.py > test.log 2>&1 >βœ… Scenario: Automation continues to execute after SSH disconnection

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

🧰 8. Other Useful Commands

18. which / whereis β€”β€” Find command location

which python    # View python path (avoid version confusion)

19. history β€”β€” View command history

history | grep curl   # Find previously used curl commands

20. alias β€”β€” Set shortcut commands

# Add to ~/.bashrc alias ll='ls -lh'alias logt='tail -f /var/log/test.log'βœ… Improve daily efficiency!

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ’‘ Advice for Automation Test Engineers

Do not just memorize commands; understanding the scenarios is more important.

Make good use of pipes | and redirection >: the power of combining commands is immense (e.g., grep ERROR log | wc -l).

Practice in the testing environment, do not be afraid to make mistakes (be cautious in production environments!).

Organize commonly used commands into a cheat sheet, post it at your workstation or save it as notes.

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

πŸ’¬ In Conclusion

Linux is not just the domain of operations and maintenance; it is the second workstation for every automation test engineer.

When you can smoothly check logs, validate services, debug interfaces, and monitor resources on the server,

you are no longer just “the script writer” but a quality guardian who can close the loop on issues.

Mastering these commands is not about becoming an operations engineer, but about doing testing more professionally.

Essential for Automation Test Engineers: 20 Linux Commands to Navigate Servers with Ease

Every interaction is encouragement, and every support promotes growth.

Business cooperation:huaan——9527

Leave a Comment