็†ฑ้–€ๅˆ†้กž
 ่ผ‰ๅ…ฅไธญ…
็›ฎ้Œ„

๐Ÿง Linux Common Errors and Troubleshooting Guide

    ๐Ÿง Linux Common Errors and Troubleshooting Guide

    Even experienced Linux administrators occasionally face issues — failed services, denied permissions, blocked ports, or SELinux restrictions. This guide summarizes the 10 most common Linux errors and provides quick diagnostic commands and recovery solutions.

    1️⃣ Permission Denied

    Appears when accessing protected files or running scripts without proper privileges.

    sudo chown -R user:user /path/to/file
    sudo chmod 755 /usr/local/bin/script.sh
    getenforce        # Check SELinux mode
    sudo restorecon -Rv /var/www/html

    Tip: Verify file ownership, permission bits, and SELinux labels.

    2️⃣ systemd Service Failed to Start

    Analyze service startup failures using:

    sudo systemctl status nginx
    sudo journalctl -xeu nginx

    Common causes: syntax errors, permission issues, or missing dependencies.

    3️⃣ Network Connection Problems

    When ping or curl cannot connect, check:

    ip a
    sudo systemctl restart NetworkManager
    curl -I https://example.com
    ss -tulnp | grep 80

    4️⃣ Firewall Blocking (Firewalld / UFW)

    After installing a service, ports might still be blocked:

    # CentOS / Rocky Linux
    sudo firewall-cmd --permanent --add-port=80/tcp
    sudo firewall-cmd --reload
    
    # Ubuntu / Debian
    sudo ufw allow 80/tcp
    sudo ufw reload

    5️⃣ Package Dependency Errors

    sudo dnf clean all && sudo dnf makecache
    sudo apt --fix-broken install

    If still failing, inspect repository configurations or use dnf repoquery to find missing packages.

    6️⃣ No Space Left on Device

    Disk full errors can stop services and updates.

    df -h
    du -sh /* | sort -h

    Clean logs with journalctl --vacuum-time=7d or remove old backups under /var/log.

    7️⃣ Out of Memory (OOM)

    Add swap space when memory is exhausted:

    sudo fallocate -l 2G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile

    8️⃣ SSH Login Failed

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
    sudo systemctl restart sshd

    Ensure PubkeyAuthentication yes is enabled in /etc/ssh/sshd_config.

    9️⃣ Update or Repository Errors

    For GPG key or repository issues:

    sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
    sudo dnf update -y

    For Ubuntu, verify mirror URLs in /etc/apt/sources.list.

    ๐Ÿ”Ÿ Auto-start Issues After Reboot

    sudo systemctl enable squid
    sudo systemctl is-enabled squid
    sudo systemctl list-dependencies multi-user.target

    Define startup order using After=network.target if needed.

    ๐Ÿ“˜ Conclusion

    Linux is stable yet highly configurable — every error message is a clue. Mastering tools like systemctl, journalctl, firewall-cmd, and ss/netstat will help you troubleshoot faster and bring systems back online efficiently.


    ๐Ÿ”— Related Articles

    — WWFandy・System & Network Notes

    ๐Ÿ”— ๅˆ†ไบซ้€™็ฏ‡ LINE Facebook X

    ๆฒ’ๆœ‰็•™่จ€:

    ๅผต่ฒผ็•™่จ€

    ๅญ—็ดš