Top 100 Linux Troubleshooting Commands (Must Know)

Trix Cyrus - Oct 5 - - Dev Community

Author: Trix Cyrus

Waymap Pentesting tool: Click Here
TrixSec Github: Click Here

1. System Monitoring and Performance

These commands help you monitor system performance, check CPU and memory usage, and identify resource bottlenecks.

top – Real-time system monitoring tool.
htop – Interactive process viewer.
uptime – Shows how long the system has been running.
free – Displays free and used memory.
vmstat – Reports on virtual memory and system activity.
iostat – Displays CPU and I/O statistics.
sar – Collects and reports system activity.
mpstat – CPU usage report for individual processors.
dstat – Real-time system resource statistics.
tload – Terminal-based graphical CPU load display.
nmon – Comprehensive system monitoring tool.
iotop – Displays real-time I/O usage by processes.
pidstat – Provides statistics on CPU usage per process.
glances – Monitoring tool with a web-based UI.
ps aux – Displays active processes with memory and CPU usage.
watch – Periodically runs and outputs the result of a command.
Enter fullscreen mode Exit fullscreen mode

2. Disk and File System Troubleshooting

When your system runs out of disk space or encounters file system errors, these commands will help you analyze and fix the issue.

df -h – Shows disk space usage in human-readable format.
du -sh – Displays directory size.
lsblk – Lists block devices.
fdisk – Partition table manipulator.
parted – Advanced disk partitioning tool.
mount – Mounts a file system.
umount – Unmounts a file system.
fsck – File system consistency check and repair.
mkfs – Creates a new file system.
blkid – Identifies block devices.
tune2fs – Adjusts file system parameters.
e2fsck – File system repair for ext2/ext3/ext4.
resize2fs – Resizes ext2/ext3/ext4 file systems.
badblocks – Searches for bad blocks on a disk.
lsof – Lists open files and the processes using them.
fstrim – Trims unused space on a SSD.
Enter fullscreen mode Exit fullscreen mode

3. Network Troubleshooting

Troubleshooting network connectivity and performance is critical for system administrators. These commands will help diagnose and resolve network issues.

ifconfig – Configures or displays network interfaces.
ip a – Displays IP address information.
netstat – Displays network connections and routing tables.
ss – Socket statistics, similar to netstat.
ping – Checks network connectivity.
traceroute – Traces the route packets take to a network host.
nslookup – Queries DNS to get information about domain names.
dig – DNS lookup utility.
mtr – Combines traceroute and ping in a network diagnostic tool.
tcpdump – Captures network packets.
wireshark – Network protocol analyzer.
nmap – Network exploration and security scanning tool.
ethtool – Configures network driver and hardware settings.
route – Displays or manipulates the IP routing table.
iptables – Configures network packet filtering rules.
ip link set – Used to change network interface states.
curl – Transfers data to/from a server.
wget – Retrieves files from the web.
hostname – Displays or sets the system’s hostname.
ss -tuln – Lists open ports and listening services.
nmcli – Network Manager command-line interface.

Enter fullscreen mode Exit fullscreen mode

4. Log Management

System logs are the first place to look when diagnosing system problems. These commands help you read and manage logs.

dmesg – Displays kernel ring buffer messages.
journalctl – Queries systemd logs.
tail -f /var/log/syslog – Continuously displays the end of the syslog file.
grep – Searches text in files (useful for logs).
less /var/log/messages – Reads system messages log file.
logrotate – Manages log file rotation.
last – Shows the last logged-in users.
who – Shows who is logged in.
uptime – Shows system uptime and user logins.
rsyslog – A powerful logging system that supports remote logging.
auditctl – Controls the audit framework in Linux.
Enter fullscreen mode Exit fullscreen mode

5. User and Permissions Management

Managing users, groups, and permissions is vital to security and system functionality. These commands help troubleshoot user access and permission problems.

id – Prints user and group IDs.
usermod – Modifies user account.
passwd – Changes user passwords.
chmod – Changes file permissions.
chown – Changes file ownership.
groups – Shows the groups a user belongs to.
sudo – Executes commands as another user.
visudo – Safely edits the sudoers file.
whoami – Displays the current user.
su – Switches to another user account.
useradd – Adds a new user.
groupadd – Adds a new group.
userdel – Deletes a user account.
lastlog – Displays the most recent login for all users.
Enter fullscreen mode Exit fullscreen mode

6. Package Management Troubleshooting

Keeping your system up-to-date and resolving package conflicts or dependency issues is crucial for system stability.

apt-get update – Updates the package index.
apt-get upgrade – Upgrades installed packages.
apt-cache search – Searches for packages in the apt-cache.
dpkg --configure -a – Configures pending package installations (Debian-based).
yum update – Updates packages on RPM-based systems.
dnf upgrade – Upgrades packages on Fedora and RHEL.
rpm -qa – Queries all installed RPM packages.
pacman -Syu – Updates packages on Arch-based systems.
apt-get install – Installs a package.
dpkg -l – Lists installed packages (Debian-based).
snap list – Lists installed snap packages.
Enter fullscreen mode Exit fullscreen mode

7. System Boot and Services Troubleshooting

When your system isn’t booting properly or services fail to start, these commands help you troubleshoot boot and service issues.

systemctl – Controls systemd services.
service – Starts, stops, and restarts services.
journalctl -xe – Views system startup errors.
chkconfig – Manages services on startup.
grub-mkconfig – Generates a new GRUB configuration.
grub-install – Installs the GRUB bootloader.
update-grub – Updates GRUB configurations.
reboot – Reboots the system.
shutdown – Shuts down the system.
fsck – Repairs file systems on boot.
init 0 – Shuts down the system.

Enter fullscreen mode Exit fullscreen mode

~Trixsec

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .