DEV Community

Ibrahim S
Ibrahim S

Posted on • Edited on

1

System Monitoring & Performance | Linux

As a DevOps engineer, mastering Linux commands is crucial for efficient system troubleshooting and management.

System Monitoring & Performance

CPU Usage:

  • top - Real-time process and resource usage.
  • htop - Enhanced process viewer.
  • sar - Historical resource usage.

Memory Usage:

  • free -h - Memory usage overview.
  • cat /proc/meminfo - Detailed memory statistics.

Disk Usage:

  • df -h - Disk usage by filesystem.
  • du -sh  - Directory size.

Network Usage:

  • netstat -tuln or ss -tuln - Active connections.
  • iftop - Real-time bandwidth usage.

- ping  - Connectivity check.

2. File and Directory Management

File Management:

  • ls -lh - List files with details.
  • cat, less, more - View file content.
  • find /path -name "*.log" - Search files.

Permissions:

  • chmod 755  - Change file permissions.
  • chown user:group  - Change ownership.

3. User and Group Management

Users:

  • id  - User details.
  • adduser  - Add a user.
  • passwd  - Change user password.

Groups:

  • groups  - User groups.
  • usermod -aG  - Add user to a group.
  • Logged-In Users:
  • who - List logged-in users.
  • last - Login history.

  • 4. Process Management

View Processes:

  • ps aux - List processes.
  • pgrep  - Search for a process.

Manage Processes:

  • kill -9  - Kill a process by ID.
  • pkill  - Kill a process by name.

Logs:

  • journalctl - View system logs.
  • dmesg - Kernel messages.
  • tail -f /var/log/ - Monitor logs in real-time.

5. Networking

Connectivity:

  • curl -I  - Test HTTP connection.
  • ping  - Test network.
  • traceroute  - Trace network route. Debugging: telnet  - Test open ports. dig  - DNS lookup.

6. Disk and Filesystem Management

Filesystem:

  • fsck /dev/sda1 - Check filesystem.
  • mount and umount - Mount/unmount filesystems.

Disk Partitioning:

  • fdisk -l - Partition details.
  • lsblk - List block devices.  - -

7. Package Management

Debian/Ubuntu:

  • apt update - Update package list.
  • apt install  - Install a package.

RHEL/CentOS:

  • yum update - Update packages.
  • yum install  - Install a package.

8. Backup and Archive

Backup:

  • rsync -av /source/ /destination/ - Sync files/directories.

Archiving:

  • tar -cvf archive.tar /path - Archive files.

- gzip archive.tar - Compress the archive.

10. General Troubleshooting Commands

  • uptime - System uptime.
  • uname -a - Kernel and OS details.

- tcpdump - Network packet capture.

End-to-End Troubleshooting Example:

1. Identify the Issue:
Use top, df -h, or ping to gather insights.

2. Narrow Down Root Cause:
Use ps aux, netstat, or iotop to trace the issue.

3. Apply Fixes:
Restart services or update packages.

4. Monitor Post-Fix:


AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)