Skip to content
Menu
DevSecOps Now!!!
  • About
  • Certifications
  • Contact
  • Courses
  • DevSecOps Consulting
  • DevSecOps Tools
  • Training
  • Tutorials
DevSecOps Now!!!

Linux Server Diagnostic Commands: Complete Guide for Performance, Network & System Troubleshooting

Posted on April 28, 2026

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

When a website, API, Laravel application, microservice, database, or authentication service suddenly becomes slow or unstable, the first mistake many people make is directly checking the application code.

But in production, many issues are not caused by code only. They can come from:

Disk full issue
Low RAM
Network routing issue
Too many open connections
DNS failure
Server port exhaustion
High socket usage
Low file descriptor limit
Database overload
Apache/Nginx/PHP-FPM pressure
Laravel log permission issue

That is why every developer, DevOps engineer, and system administrator should know these basic Linux diagnostic commands:

ip route
ip addr
df -h
free -m
ulimit -n
cat /proc/sys/net/ipv4/ip_local_port_range
ss -s

These commands help you understand the server condition before making any major change.


1. ip route Command

What is ip route?

The ip route command shows the routing table of your Linux server.

In simple words, it tells the server:

Where should network traffic go?
Which gateway should be used?
Which network interface is responsible for internet traffic?
How does the server reach external IPs?

Command

ip route

Example Output

default via 172.31.0.1 dev eth0
172.31.0.0/20 dev eth0 proto kernel scope link src 172.31.6.53

Meaning of Output

default via 172.31.0.1

This means all internet traffic goes through gateway:

172.31.0.1

This is very important. If the default route is missing, your server may not connect to external services.

dev eth0

This means the network interface being used is:

eth0

In some servers, it may be:

ens3
ens5
enp0s3

src 172.31.6.53

This is the private IP address of the server.

Why ip route is Important

Use this command when:

Your server cannot access the internet
Git pull or git push is failing
Curl request is not working
Keycloak cannot connect
Laravel Guzzle request is failing
API calls are timing out
DNS looks correct but external connection still fails

Practical Debugging Example

Suppose this command fails:

curl -I https://github.com

Then first check routing:

ip route

If there is no line starting with:

default via

then your server has no default gateway.

That means the server does not know how to send traffic outside its local network.

Safe Command

ip route

This is completely safe. It only reads information.


2. ip addr Command

What is ip addr?

The ip addr command shows all network interfaces and IP addresses configured on the server.

Command

ip addr

Example Output

1: lo: <LOOPBACK,UP,LOWER_UP>
    inet 127.0.0.1/8

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 172.31.6.53/20

Important Parts

lo

This is the loopback interface.

127.0.0.1

It is used internally by the server.

eth0

This is the main network interface.

UP

This means the network interface is active.

inet

This shows the IPv4 address.

Example:

inet 172.31.6.53/20

Why ip addr is Important

Use it when:

You want to know server IP
You want to check whether network interface is active
Apache/Nginx binding issue is suspected
Keycloak or Laravel app is listening on a wrong interface
Server cannot be reached from outside
Internal microservices cannot communicate

Practical Example

If Apache or Keycloak is running but website is not opening, check:

ip addr

Then confirm the server has the expected IP address.

Also check:

ss -tulpn

This will show which service is listening on which port.

Safe Command

ip addr

This is safe. It only displays network information.


3. df -h Command

What is df -h?

The df -h command shows disk usage of mounted filesystems.

Command

df -h

Example Output

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        80G   74G  3.5G  96% /
tmpfs           2.0G     0  2.0G   0% /dev/shm

Meaning of Columns

Filesystem

The disk or partition name.

Example:

/dev/sda1

Size

Total disk size.

Used

Used disk space.

Avail

Free disk space available.

Use%

Percentage of disk used.

Mounted on

Where the disk is mounted.

Example:

/

means root filesystem.

Why df -h is Critical

Disk full can break many things.

For Laravel, disk full can cause:

500 error
Session write failure
Cache write failure
Log file not created
File upload failure
View cache generation failure
Queue failure
Composer install failure
Database write issues

Dangerous Disk Usage Levels

Below 70%

Usually safe.

70% to 85%

Monitor carefully.

85% to 90%

Start cleanup.

90% to 95%

Risky for production.

Above 95%

Critical. Website may fail anytime.

Common Production Error Due to Disk Full

You may see errors like:

file_put_contents(...): Failed to open stream

or:

No space left on device

or Laravel may stop writing logs.

Next Commands After df -h

If disk is full, check which folder is heavy:

du -sh /*

Then go deeper:

du -sh /var/*
du -sh /opt/*
du -sh /opt/lampp/*
du -sh /opt/lampp/htdocs/*

For Laravel projects:

du -sh storage/*
du -sh storage/logs/*
du -sh storage/app/public/*

Find large files:

find /opt/lampp/htdocs -type f -size +100M -exec ls -lh {} \;

Find large log files:

find / -type f -name "*.log" -size +100M 2>/dev/null

Safe Cleanup Examples

Clear Laravel logs carefully:

> storage/logs/laravel.log

This empties the log file but keeps the file.

Do not randomly delete system files.

Safe Command

df -h

It is safe. It only reads disk usage.


4. free -m Command

What is free -m?

The free -m command shows RAM usage in megabytes.

Command

free -m

Example Output

              total        used        free      shared  buff/cache   available
Mem:           7945        6120         420         120        1405        1510
Swap:          2047         300        1747

Meaning of Columns

total

Total RAM installed.

used

RAM currently used.

free

Completely unused RAM.

buff/cache

Memory used for caching.

available

Most important column.

It shows how much memory is available for new processes.

Do Not Only Look at free

Many beginners see low free memory and think the server is in trouble.

That is not always true.

Linux uses free RAM for cache, which is normal.

The most important column is:

available

When RAM is a Problem

If available memory is very low, for example:

available: 100 MB

then server may become slow.

You may face:

Slow website
Database slowdown
PHP-FPM workers killed
MySQL crash
Keycloak Java process memory pressure
Composer command killed
Laravel queue workers killed

Check Top Memory Processes

Use:

ps aux --sort=-%mem | head -20

This shows top memory-consuming processes.

You may see:

mysql
apache2
php-fpm
java
node

Real Production Use Case

If your Laravel website is slow:

First run:

free -m

Then:

ps aux --sort=-%mem | head -20

If MySQL or Java is consuming most memory, optimize that service instead of blaming Laravel directly.

Safe Command

free -m

It is completely safe.


5. ulimit -n Command

What is ulimit -n?

The ulimit -n command shows how many files a process can open at one time.

Command

ulimit -n

Example Output

1024

What Does โ€œOpen Fileโ€ Mean?

In Linux, many things are treated like files:

Normal files
Log files
Network sockets
Database connections
API connections
Pipes
Temporary files

So this limit affects web servers, APIs, databases, and microservices.

Why It Matters

If this value is too low, high-traffic applications can fail with:

Too many open files

This can affect:

Apache
Nginx
PHP-FPM
MySQL
Redis
Node.js
Java Keycloak
Laravel queue workers

Good Production Value

For small servers:

4096

For production servers:

65535

For high-traffic systems:

100000+

Temporary Increase

ulimit -n 65535

But this applies only to the current shell/session.

Permanent Configuration

Usually set in:

/etc/security/limits.conf

Example:

www-data soft nofile 65535
www-data hard nofile 65535
root soft nofile 65535
root hard nofile 65535

For systemd services, also check service file:

LimitNOFILE=65535

Then reload systemd:

sudo systemctl daemon-reload
sudo systemctl restart apache2

or for Keycloak:

sudo systemctl restart keycloak

Safe Command

ulimit -n

Safe. It only shows the current limit.


6. cat /proc/sys/net/ipv4/ip_local_port_range

What is This?

This command shows the local ephemeral port range.

Command

cat /proc/sys/net/ipv4/ip_local_port_range

Example Output

32768 60999

What Are Ephemeral Ports?

When your server makes an outgoing connection, Linux uses a temporary local port.

Example:

Your Laravel app calls:

https://auth.myhospitalnow.com

The server may use a temporary local port like:

45231

That port stays in use during the connection.

Why It Matters

If your server makes too many outgoing connections, it can run out of temporary ports.

This is called port exhaustion.

When Port Exhaustion Happens

It can happen when:

Laravel makes many Guzzle requests
Microservices call each other frequently
Keycloak token validation happens too often
API calls do not reuse connections
Too many TIME_WAIT sockets exist
High traffic comes suddenly
External API is slow and connections stay open

Symptoms

You may see:

Connection timeout
Cannot assign requested address
Random API failure
Guzzle connection exception
Slow external API calls
Intermittent login failure

Check Current Range

cat /proc/sys/net/ipv4/ip_local_port_range

Default may be:

32768 60999

This gives around 28,000 ports.

Better Production Range

10000 65000

Temporary Change

sudo sysctl -w net.ipv4.ip_local_port_range="10000 65000"

Permanent Change

Edit:

sudo nano /etc/sysctl.conf

Add:

net.ipv4.ip_local_port_range = 10000 65000

Apply:

sudo sysctl -p

Important Warning

Do not change kernel/network settings blindly on production.

First check socket status:

ss -s

and TIME_WAIT count:

ss -tan state time-wait | wc -l

Safe Command

cat /proc/sys/net/ipv4/ip_local_port_range

Safe. It only reads the setting.


7. ss -s Command

What is ss -s?

The ss -s command shows summary of network sockets.

Command

ss -s

Example Output

Total: 850
TCP:   620 (estab 120, closed 300, orphaned 0, timewait 400)

Transport Total     IP        IPv6
RAW       0         0         0
UDP       8         6         2
TCP       320       280       40
INET      328       286       42

Important Terms

estab

Established active connections.

timewait

Connections that were closed but are still waiting before being fully released.

orphaned

Connections no longer attached to a process.

closed

Closed connections.

Why TIME_WAIT Matters

TIME_WAIT is normal.

But too many TIME_WAIT connections can cause:

Port exhaustion
Slow network performance
API failures
High socket usage

Check TIME_WAIT Count

ss -tan state time-wait | wc -l

Check Established Connections

ss -tan state established | wc -l

Check Listening Ports

ss -tulpn

This shows which services are listening.

Example:

tcp LISTEN 0 511 0.0.0.0:80
tcp LISTEN 0 511 0.0.0.0:443
tcp LISTEN 0 128 127.0.0.1:3306
tcp LISTEN 0 4096 0.0.0.0:8080

Real Use Case

If Keycloak is running, check:

ss -tulpn | grep -E '8080|8443'

If Apache is running:

ss -tulpn | grep -E ':80|:443'

If MySQL is running:

ss -tulpn | grep 3306

Safe Command

ss -s

Safe. It only shows socket summary.


Complete Production Troubleshooting Workflow

Case 1: Website is Very Slow

Run these commands:

free -m
df -h
ss -s
ps aux --sort=-%mem | head -20
ps aux --sort=-%cpu | head -20

What to Check

If RAM is low:

Check memory-heavy process.

If disk is above 90%:

Clean logs, old backups, cache files.

If socket count is very high:

Check Apache/Nginx/PHP-FPM/database connections.


Case 2: Laravel 500 Error

Run:

df -h
free -m
ls -ld storage bootstrap/cache
ls -lh storage/logs
tail -100 storage/logs/laravel.log

Common Causes

Disk full
Permission issue
Cache write issue
Log file not writable
Database connection failure
PHP memory limit
Composer autoload issue

Permission Fix Example

sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache

For XAMPP/LAMPP, Apache user may be different. Check with:

ps aux | grep httpd
ps aux | grep apache

Case 3: API or Guzzle Request Failing

Run:

ip route
ip addr
cat /etc/resolv.conf
curl -I https://example.com
ss -s
cat /proc/sys/net/ipv4/ip_local_port_range

What to Check

Default route exists
DNS server is correct
External URL is reachable
Too many sockets are not open
Port range is not too small


Case 4: GitHub Pull or Push Not Working

Run:

ip route
ip addr
curl -I https://github.com
nslookup github.com
ssh -T git@github.com

Common Issues

DNS failure
SSH key issue
Remote origin missing
Network route problem
Firewall issue

Check remote:

git remote -v

If origin is missing:

git remote add origin git@github.com:OWNER/REPO.git

Case 5: Keycloak Login or Token Issue

Run:

systemctl status keycloak --no-pager
ss -tulpn | grep -E '8080|8443'
ip route
ip addr
curl -I https://auth.yourdomain.com
journalctl -u keycloak -n 100 --no-pager

What to Check

Keycloak service running
Port is listening
Domain resolves correctly
Apache/Nginx reverse proxy works
Server can reach database
No memory pressure


Recommended Daily Server Health Checklist

Run:

df -h
free -m
ss -s
uptime

Check:

Disk usage below 85%
Available RAM is healthy
Socket count is normal
Load average is not too high


Recommended Deep Diagnostic Command Set

For a full server check:

echo "===== DISK ====="
df -h

echo "===== MEMORY ====="
free -m

echo "===== LOAD ====="
uptime

echo "===== ROUTE ====="
ip route

echo "===== IP ADDRESS ====="
ip addr

echo "===== PORT RANGE ====="
cat /proc/sys/net/ipv4/ip_local_port_range

echo "===== SOCKET SUMMARY ====="
ss -s

echo "===== LISTENING PORTS ====="
ss -tulpn

echo "===== TOP MEMORY PROCESSES ====="
ps aux --sort=-%mem | head -20

echo "===== TOP CPU PROCESSES ====="
ps aux --sort=-%cpu | head -20

Safe vs Risky Commands

Safe Commands

These only read information:

ip route
ip addr
df -h
free -m
ulimit -n
cat /proc/sys/net/ipv4/ip_local_port_range
ss -s
ss -tulpn
ps aux
uptime

Be Careful With These

These change server settings:

sysctl -w
systemctl restart
rm -rf
chmod -R
chown -R
truncate
kill
reboot

Always understand before running them.


Final Conclusion

These Linux commands are not small commands. They are the foundation of real production troubleshooting.

With them, you can diagnose:

Network issues
DNS problems
Disk full errors
RAM pressure
Laravel 500 errors
Guzzle/API failures
Keycloak connectivity issues
Too many open files
Port exhaustion
High socket usage
Server performance problems

For production debugging, always follow this order:

First check disk.
Then check memory.
Then check network route.
Then check sockets.
Then check ports.
Then check service logs.
Then check application logs.

This approach saves time, avoids guesswork, and helps you fix real problems safely.

Post Views: 9
  • linux devops troubleshooting commands
  • linux diagnostic commands
  • linux disk usage command df -h
  • linux memory usage command free -m
  • linux network troubleshooting commands
  • linux performance tuning commands
  • linux port exhaustion troubleshooting
  • linux production debugging
  • Linux Server
  • linux server health check
  • linux server optimization guide
  • linux server performance issues fix
  • linux server troubleshooting
  • linux socket monitoring ss command
  • linux system monitoring commands
  • linux ulimit open files limit
Subscribe
Login
Notify of
guest
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
  • Linux Server Diagnostic Commands: Complete Guide for Performance, Network & System Troubleshooting
  • The Ultimate Guide to CDOM โ€“ Certified DataOps Manager Certification
  • The Practical Path to AI Reliability: A Guide to the Certified MLOps Manager
  • Master the Machine Learning Lifecycle:Guide to Becoming a Certified MLOps Architect
  • How to Build a Project-Level AI Memory System That Works Across Codex, Claude, and Other AI Coding Tools
  • Certified MLOps Professional: A Deep Dive into the Certified MLOps Professional Certification
  • Certified MLOps Engineer : The Comprehensive Guide to Mastering Machine Learning Operations
  • Codex vs Claude: A Complete Practical Guide for Modern Developers (2026)
  • Certified AIOps Professional Program A Guide to Career Growth
  • Keycloak Multi-Client Architecture with Project-Based Email Validation (Student, Trainer, Company, Consulting)
  • Incorrect definition of table mysql.column_stats
  • Mautic and PHP 8.3 Compatibility Guide (2026)
  • Certified AIOps Engineer: The Complete Career Path and Certification Guide
  • How to Rename Apache Virtual Host Files Safely (Step-by-Step Guide for Linux)
  • AIOps Foundation Certification: Everything You Need to Know to Get Certified
  • DevOps to Certified Site Reliability Professional: A Senior Mentorโ€™s Guide
  • Certified Site Reliability Manager Training, Preparation, and Career Mapping
  • Certified Site Reliability Architect: The Complete Career Guide
  • What Is a VPN? A Complete Beginner-to-Advanced Tutorial
  • How to Install, Secure, and Tune MySQL 8.4 on Ubuntu 24.04 for Apache Event MPM and PHP-FPM
  • Complete Guide to Certified Site Reliability Engineer Career
  • Certified DevSecOps Professional Step by Step
  • Certified DevSecOps Manager: Complete Career Guide
  • Certified DevSecOps Engineer: Skills, Career Path and Certification Guide
  • Step-by-Step: Become a Certified DevSecOps Architect
  • Tuning PHP 8.3 for Apache Event MPM and PHP-FPM on Ubuntu: A Complete Step-by-Step Production Guide
  • Complete Step-by-Step Guide to Configure Apache Event MPM, Create index.php, Set Up VirtualHost, and Fix Ubuntu Default Page
  • Convert XAMPP Apache to Event MPM + System PHP-FPM
  • The Gateway to System Observability Engineering (MOE)
  • How to Finetune Apache and Prove It Works: A Real-World Guide to Testing Performance, Concurrency, HTTP/2, Memory, CPU, and Security

Recent Comments

  1. emmy day on SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘provider’ in ‘field list’
  2. digital banking on Complete Tutorial: Setting Up Laravel Telescope Correctly (Windows + XAMPP + Custom Domain)
  3. SAHIL DHINGRA on How to Uninstall Xampp from your machine when it is not visible in Control panel programs & Feature ?
  4. Abhishek on MySQL: List of Comprehensive List of approach to secure MySQL servers.
  5. Kristina on Best practices to followed in .httacess to avoid DDOS attack?

Archives

  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022

Categories

  • Ai
  • AI Blogging
  • AiOps
  • ajax
  • Android Studio
  • Antimalware
  • Antivirus
  • Apache
  • Api
  • API Security
  • Api Testing
  • APK
  • Aws
  • Bike Rental Services
  • ChatGPT
  • Code Linting
  • Composer
  • cPanel
  • Cyber Threat Intelligence
  • Cybersecurity
  • Data Loss Prevention
  • Database
  • dataops
  • Deception Technology
  • DeepSeek
  • Devops
  • DevSecOps
  • DevTools
  • Digital Asset Management
  • Digital Certificates
  • Docker
  • Drupal
  • emulator
  • Encryption Tools
  • Endpoint Security Tools
  • Error
  • facebook
  • Firewalls
  • Flutter
  • git
  • GITHUB
  • Google Antigravity
  • Google play console
  • Google reCAPTCHA
  • Gradle
  • Guest posting
  • health and fitness
  • IDE
  • Identity and Access Management
  • Incident Response
  • Instagram
  • Intrusion Detection and Prevention Systems
  • jobs
  • Joomla
  • Keycloak
  • Laravel
  • Law News
  • Lawyer Discussion
  • Legal Advice
  • Linkedin
  • Linkedin Api
  • Linux
  • Livewire
  • Mautic
  • Medical Tourism
  • MlOps
  • MobaXterm
  • Mobile Device Management
  • Multi-Factor Authentication
  • MySql
  • Network Traffic Analysis tools
  • Paytm
  • Penetration Testing
  • php
  • PHPMyAdmin
  • Pinterest Api
  • Quora
  • SAST
  • SecOps
  • Secure File Transfer Protocol
  • Security Analytics Tools
  • Security Auditing Tools
  • Security Information and Event Management
  • Seo
  • Server Management Tools
  • Single Sign-On
  • Site Reliability Engineering
  • soft 404
  • software
  • SuiteCRM
  • SysOps
  • Threat Model
  • Twitter
  • Twitter Api
  • ubuntu
  • Uncategorized
  • Virtual Host
  • Virtual Private Networks
  • VPNs
  • Vulnerability Assessment Tools
  • Web Application Firewalls
  • Windows Processor
  • Wordpress
  • WSL (Windows Subsystem for Linux)
  • X.com
  • Xampp
  • Youtube
©2026 DevSecOps Now!!! | WordPress Theme: EcoCoded
wpDiscuz