Skip to content

Linux Error Fixes -- Permission Denied, Package Not Found & Segfault

DodaTech Updated 2026-06-22 4 min read

Linux errors like permission denied, package not found, and segmentation faults halt development instantly -- this guide shows you how to diagnose and fix each one with exact commands and real output.

What You'll Learn

Why It Matters

Every Linux user hits these errors daily. Knowing how to fix them without Googling every time saves hours and makes you a more effective developer.

Real-World Use

Whether you are deploying on a production server, running a CI/CD pipeline with GitHub Actions, or building software on your local machine, these fixes keep your work moving.

Common Linux Errors Table

Error Message Cause Fix
Permission denied File or directory lacks execute/read permission Use chmod or chown to correct permissions
command not found Binary not in PATH or not installed Install the package or update PATH
Segmentation fault (core dumped) Program accessed invalid memory Fix null pointers, buffer overflows in code
No space left on device Disk partition is full Delete files or extend the partition
Package not found APT/YUM/DNF repo does not have the package Update repos or add the correct PPA

Step-by-Step Fixes

Fix 1: Permission Denied

# Check current permissions
ls -la /path/to/file

# Add execute permission for the owner
chmod u+x /path/to/file

# Change file ownership
sudo chown user:group /path/to/file

Expected output:

-rwxr--r-- 1 user group 1024 Jun 22 10:00 /path/to/file

Fix 2: Command Not Found

# Verify the command is not installed
which htop

# Install on Debian/Ubuntu
sudo apt update && sudo apt install htop -y

# Install on RHEL/CentOS/Fedora
sudo dnf install htop -y

# Find which package provides a command
apt-file search htop

Expected output:

/usr/bin/htop    # after successful install

Fix 3: Segmentation Fault

# Compile with debug symbols
gcc -g -o program program.c

# Run with GDB
gdb ./program
(gdb) run
(gdb) bt

Expected output:

#0  0x0000555555554716 in cause_segfault () at program.c:10
#1  0x0000555555554734 in main () at program.c:15

Fix 4: No Space Left on Device

# Check disk usage
df -h

# Find large files
du -sh /* 2>/dev/null | sort -rh | head -10

# Clean package cache
sudo apt clean && sudo apt autoremove -y

# Find and remove old logs
sudo journalctl --vacuum-time=7d

Expected output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        50G   50G     0 100% /

Fix 5: Package Not Found

# Update package lists
sudo apt update

# Search for the package
apt search <package-name>

# Add a PPA (Ubuntu)
sudo add-apt-repository ppa:<name>/<ppa>
sudo apt update
sudo apt install <package> -y

Expected output:

Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Reading package lists... Done

Common Linux Errors Flowchart

flowchart TD
    A[Linux Error Occurs] --> B{Error Type?}
    B -->|Permission Denied| C[Check ls -la permissions]
    C --> D[Run chmod/chown]
    B -->|Command Not Found| E[Check PATH with which]
    E --> F[Install package or add to PATH]
    B -->|Segfault| G[Compile with -g flag]
    G --> H[Debug with GDB backtrace]
    B -->|Disk Full| I[Run df -h]
    I --> J[Clean logs and temp files]
    D --> K[Error Resolved]
    F --> K
    H --> K
    J --> K

Prevention Tips

  • Use sudo only when necessary to avoid accidental permission changes
  • Keep packages updated with regular apt update && apt upgrade
  • Always compile with -Wall -Wextra flags to catch memory errors early
  • Monitor disk usage with df -h and set up alerts at 80% capacity
  • Use valgrind or AddressSanitizer during development to catch segfaults before production

Practice Questions

  1. What command shows the current permissions of a file? Answer: ls -la <filename> shows detailed permissions, owner, and group.

  2. How do you find which package provides a command on Ubuntu? Answer: Use apt-file search <command> or dpkg -S $(which <command>).

  3. What does a segmentation fault indicate? Answer: The program tried to access memory it did not have permission to access, often due to null pointer dereference or buffer overflow.

  4. How can you free up disk space quickly? Answer: Run sudo apt clean, sudo journalctl --vacuum-time=7d, and check large files with du -sh /*.

  5. Challenge: Write a shell script that checks disk usage, warns if any partition is above 80%, and lists the top 5 largest directories in /home. Answer:

    #!/bin/bash
    df -h | awk 'NR>1 {print $5, $6}' | while read -r pct mount; do
        pct=${pct%\%}
        if [ "$pct" -gt 80 ]; then
            echo "WARNING: $mount is ${pct}% full"
        fi
    done
    du -sh /home/* 2>/dev/null | sort -rh | head -5
    

Quick Reference

Error Quick Command Notes
Permission denied chmod 755 <file> Numeric mode is faster than symbolic
Command not found sudo apt install <pkg> Use which to verify first
Segfault gdb -batch -ex run -ex bt ./prog Compile with -g flag
Disk full sudo apt clean && sudo journalctl --vacuum-time=7d Check du -sh /* first
Package not found sudo add-apt-repository ppa:... Always apt update after adding repos

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro