On an init-based Linux system, you should run the `service –status-all` command to check for network service issues. This simple command gives you a quick overview of all services, including network-related ones, and shows whether they are running, stopped, or have any problems. If you’re managing a server or troubleshooting connectivity, this is your first go-to tool.
Network services are the backbone of any Linux system—they handle everything from web traffic to email delivery. When something goes wrong, you need to know exactly what command to use. In this guide, we’ll walk through the best commands for checking network services on init-based systems, with practical steps and real-world examples.
What Command Should You Use On An Init Based Linux System To Check For Issues With Network Services
The `service –status-all` command is your primary weapon. It lists every service registered with the init system, including network services like networking, sshd, httpd, and iptables. Each service shows a status indicator: [+] for running, [-] for stopped, or [?] for unknown.
But that’s just the starting point. For deeper troubleshooting, you’ll need a few more commands. Let’s break down the full toolkit.
Understanding Init Based Linux Systems
Init-based systems use the traditional System V init (SysVinit) or its derivatives. These systems manage services through scripts in /etc/init.d/. Common examples include older versions of Debian, Ubuntu (before systemd), CentOS 6, and many embedded Linux distributions.
Key characteristics:
- Services start in a specific order defined by runlevels
- Service scripts are located in /etc/init.d/
- The `service` command is the primary interface
- Configuration files are in /etc/default/ or /etc/sysconfig/
Step By Step Guide To Using Service Status All
Here’s how to run the command and interpret the output:
- Open a terminal with root or sudo access
- Type:
service --status-all - Look for network-related services like networking, network, ssh, httpd, nginx, or iptables
- A [+] means the service is running
- A [-] means it’s stopped
- A [?] means the status is unknown—this often indicates a problem
For example, if you see [?] networking, that’s a red flag. It means the init script didn’t return a proper status, which could indicate a configuration error or a missing dependency.
Checking Specific Network Services
Once you identify a problematic service, check its individual status:
service networking status
This gives you detailed output, including interface status, IP addresses, and error messages. For SSH:
service ssh status
For web servers:
service httpd status (Apache on CentOS/RHEL)
service apache2 status (Apache on Debian/Ubuntu)
Common Network Service Issues And How To Fix Them
Here are frequent problems you’ll encounter:
- Service won’t start – Check logs in /var/log/syslog or /var/log/messages
- Service stops unexpectedly – Look for resource exhaustion or configuration errors
- Network interface down – Use
ifconfigorip addrto verify - Firewall blocking traffic – Check iptables rules with
service iptables status - DNS resolution failing – Test with
nslookupordig
Using Init Scripts Directly
Sometimes the `service` command doesn’t work properly. In that case, you can run the init script directly:
/etc/init.d/networking status
This bypasses the service wrapper and gives you raw output. It’s especially useful when the service command returns [?] for a service that’s actually running.
Checking All Running Network Services
For a more comprehensive view, combine commands:
service --status-all 2>&1 | grep -E 'net|ssh|http|ftp|dns|iptables'
This filters the output to show only network-related services. You can adjust the grep pattern to match your specific services.
Log Files For Network Service Troubleshooting
When the status command shows an issue, logs are your best friend. Key log files:
- /var/log/syslog – General system log
- /var/log/messages – Alternative system log (CentOS/RHEL)
- /var/log/daemon.log – Service-specific messages
- /var/log/secure – Authentication and SSH logs
- /var/log/httpd/error_log – Apache errors
Use tail -f /var/log/syslog to watch logs in real time while you restart services.
Restarting Network Services Safely
After identifying issues, you’ll likely need to restart services. Always do this carefully:
- First, stop the service:
service networking stop - Check that it stopped:
service networking status - Start it again:
service networking start - Verify it’s running:
service networking status
For a quick restart: service networking restart. But be cautious—this drops all connections momentarily.
Advanced Troubleshooting With Init Based Systems
Sometimes the basic commands aren’t enough. Here are advanced techniques:
- Check runlevels:
chkconfig --list networkingshows which runlevels the service starts in - Verify dependencies: Look at the init script header for Required-Start and Required-Stop lines
- Test configuration: Many services have a config test option, e.g.,
httpd -t - Use strace:
strace -f service networking statusshows system calls
Comparing Init Based Vs Systemd Commands
If you’re used to systemd, the commands are different. Here’s a quick comparison:
| Task | Init Based | Systemd |
|---|---|---|
| List all services | service –status-all | systemctl list-units –type=service |
| Check status | service name status | systemctl status name |
| Start service | service name start | systemctl start name |
| Enable at boot | chkconfig name on | systemctl enable name |
This table helps if you’re migrating between systems or managing mixed environments.
Automating Network Service Checks
For production servers, automate checks with a simple script:
#!/bin/bash
for service in networking ssh httpd iptables; do
if service $service status > /dev/null 2>&1; then
echo "$service is running"
else
echo "WARNING: $service has issues"
service $service status
fi
done
Run this via cron to get daily reports. It catches problems before users notice.
Common Pitfalls When Using Service Status All
Watch out for these mistakes:
- Running as non-root – Some services require root to check status
- Ignoring [?] status – Always investigate unknown statuses
- Forgetting to check dependencies – A service might fail because its dependency isn’t running
- Not checking logs – Status output is often brief; logs have the details
- Assuming service names – The service name might differ from what you expect (e.g., httpd vs apache2)
Real World Example Troubleshooting Network Services
Let’s walk through a real scenario. You run service --status-all and see:
[+] sshd [-] networking [?] iptables [+] httpd
Networking is stopped and iptables has unknown status. Here’s what to do:
- Check networking status:
service networking status– It says “interface eth0 not configured” - Check /etc/network/interfaces – You find a typo in the IP address
- Fix the configuration file
- Start networking:
service networking start - Now check iptables:
service iptables status– It shows rules but status is unknown because the init script is broken - Run iptables directly:
iptables -L -n– Rules are active - Fix the init script or ignore the [?] since the firewall is working
This example shows how to combine commands for effective troubleshooting.
When Service Status All Doesn’t Work
Sometimes the command fails entirely. Common causes:
- The service command isn’t installed (rare but possible)
- Init scripts are missing or corrupted
- The system uses a different init system (like systemd or Upstart)
- Permission issues prevent reading script status
In these cases, fall back to checking /etc/init.d/ directly or use ps aux | grep service-name to see if processes are running.
Best Practices For Network Service Management
Follow these guidelines to minimize issues:
- Always verify status after making changes
- Keep backups of configuration files
- Use version control for critical configs
- Monitor services with a tool like Nagios or Zabbix
- Document your network setup for quick reference
- Test changes in a staging environment first
Additional Commands For Network Diagnostics
Beyond service status, use these for deeper checks:
netstat -tulpn– Shows listening ports and associated servicesss -tulpn– Modern alternative to netstatlsof -i– Lists open network connectionsping– Basic connectivity testtraceroute– Path analysisnmap– Port scanning (install separately)
Understanding Service Status Codes
Each init script returns a status code:
- 0 – Service is running
- 1 – Service is dead but PID file exists
- 2 – Service is dead but lock file exists
- 3 – Service is not running
- 4 – Service status is unknown
The `service` command translates these into the [+] [-] [?] symbols. Knowing the codes helps when scripting.
Securing Network Services
When troubleshooting, also check security:
- Ensure unnecessary services are disabled:
chkconfig service off - Verify firewall rules are correct
- Check for open ports that shouldn’t be open
- Review authentication logs for unauthorized access
Migrating From Init To Systemd
If you’re planning to upgrade, know that systemd uses different commands. The `service` command still works as a compatibility wrapper on most modern systems, but it’s better to learn systemctl. Plan your migration carefully to avoid service disruptions.
Frequently Asked Questions
What Is The Difference Between Service Status All And Systemctl List Units?
Service –status-all works on init-based systems and shows services managed by SysVinit scripts. Systemctl list-units is for systemd systems and shows all active units, including services, sockets, and timers. The output format is also different—systemd gives more detail but can be overwhelming.
Can I Use Service Status All On A Systemd Based Linux?
Yes, most systemd distributions include a compatibility layer that translates service commands to systemctl. However, the output may not be complete. It’s better to use systemctl directly on systemd systems for accurate results.
What Should I Do If Service Status All Shows Unknown For A Network Service?
First, check the service individually with service name status. If that also shows unknown, look at the init script for errors. Check logs in /var/log/syslog. You can also run the init script manually with bash -x /etc/init.d/name status to see where it fails.
How Do I Check If A Network Service Is Enabled At Boot On Init Based Systems?
Use the chkconfig command: chkconfig –list service-name. It shows which runlevels the service starts in. If it’s enabled in runlevels 2, 3, 4, and 5, it will start automatically. You can also check the symbolic links in /etc/rc.d/rc*.d/ directories.
Why Does Service Networking Status Show Stopped Even Though I Have Internet?
This usually means the networking service script isn’t managing your interfaces properly. Your network might be configured via NetworkManager or a different method. Check with ifconfig or ip addr to see your actual interface status. The service status only reflects what the init script knows.
Remember, the key command for checking network services on an init-based system is `service –status-all`. It gives you a quick snapshot, but always follow up with individual service checks and log reviews for complete troubleshooting. Practice these commands on a test system first, and you’ll be ready to handle any network service issue that comes your way.