DEV Community

Ibrahim S
Ibrahim S

Posted on • Edited on

1 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:


Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay