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 -aList All Active Network Connections (TCP and UDP)
To view all active network connections, including TCP and UDP:
netstat -aList Active TCP Connections
To view only active TCP connections:
netstat -atDisplay Network Statistics for Ports
To show network statistics related to ports:
netstat -sPerform DNS Lookup for a Domain Name
To perform a DNS lookup for a specific domain:
nslookup example.comPerform DNS Query Using the dig Command
To query DNS records for a domain:
dig example.comSystem Commands
Display System Uptime
To show how long the system has been running:
uptimeDisplay Who Is Currently Logged In and What They Are Doing
To view a list of logged-in users and their activities:
wDisplay System Resource Usage, Processes, and Their Resource Consumption
To display system resource usage and active processes:
topFor an enhanced view with a more user-friendly interface:
htopDisplay System Memory Usage
To view current memory usage:
free -hList Open Files and the Processes That Opened Them
To list all open files and their associated processes:
lsofList Block Devices (Disk Drives and Partitions)
To list all block devices, such as disks and partitions:
lsblkTo view block device information including filesystem types:
blkidDisplay System Information, Including the Kernel Version
To show detailed system information and kernel version:
uname -aTo display the system hostname:
hostnameTo display the current user:
whoamiTo display user and group ID information:
idDisplay Information About the Operating System Distribution
To show details about the operating system distribution:
cat /etc/os-releaseList All Running Processes
To list all currently running processes:
psList All Processes (Including Those Owned by Other Users)
To list all processes, including those owned by other users:
ps -aList Processes in a Tree-Like Format
To view processes in a hierarchical (parent-child) format:
ps -jTList Background Jobs
To list jobs running in the background:
jobsCheck for Running Processes Containing "php" in Their Names
To find running processes with "php" in their names:
ps -f | grep phpDisplay System Hostname and Related Information
To view the system hostname and related settings:
hostnamectl statusConclusion
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.