Introduction
This guide provides a comprehensive overview of essential network and system commands used for monitoring, troubleshooting, and managing Linux systems. These commands help you gather information about network interfaces, active connections, system resources, and more.
Network Commands
Display Network Interface Information for All Interfaces
To display detailed information about all network interfaces:
ifconfig -a
List All Active Network Connections (TCP and UDP)
To view all active network connections, including TCP and UDP:
netstat -a
List Active TCP Connections
To view only active TCP connections:
netstat -at
Display Network Statistics for Ports
To show network statistics related to ports:
netstat -s
Perform DNS Lookup for a Domain Name
To perform a DNS lookup for a specific domain:
nslookup example.com
Perform DNS Query Using the dig
Command
To query DNS records for a domain:
dig example.com
System Commands
Display System Uptime
To show how long the system has been running:
uptime
Display Who Is Currently Logged In and What They Are Doing
To view a list of logged-in users and their activities:
w
Display System Resource Usage, Processes, and Their Resource Consumption
To display system resource usage and active processes:
top
For an enhanced view with a more user-friendly interface:
htop
Display System Memory Usage
To view current memory usage:
free -h
List Open Files and the Processes That Opened Them
To list all open files and their associated processes:
lsof
List Block Devices (Disk Drives and Partitions)
To list all block devices, such as disks and partitions:
lsblk
To view block device information including filesystem types:
blkid
Display System Information, Including the Kernel Version
To show detailed system information and kernel version:
uname -a
To display the system hostname:
hostname
To display the current user:
whoami
To display user and group ID information:
id
Display Information About the Operating System Distribution
To show details about the operating system distribution:
cat /etc/os-release
List All Running Processes
To list all currently running processes:
ps
List All Processes (Including Those Owned by Other Users)
To list all processes, including those owned by other users:
ps -a
List Processes in a Tree-Like Format
To view processes in a hierarchical (parent-child) format:
ps -jT
List Background Jobs
To list jobs running in the background:
jobs
Check for Running Processes Containing "php" in Their Names
To find running processes with "php" in their names:
ps -f | grep php
Display System Hostname and Related Information
To view the system hostname and related settings:
hostnamectl status
Conclusion
These commands are essential for managing and troubleshooting Linux systems. They provide valuable insights into network status, system resource usage, and active processes, helping you effectively monitor and maintain your system.
This guide covers a range of commands to help you manage and troubleshoot Linux systems, including network-related commands, system resource commands, and process management commands.