I'm getting an error every time I try to run commands on my RPi:

pi@rpi ~ $ apt-get install wkhtmltopdf
Segmentation fault

Even when I try running other commands:

pi@rpi ~ $ uptime
-bash: /usr/bin/uptime: cannot execute binary file

But others work:

pi@rpi ~ $ w
 09:09:24 up 8 days, 15:01,  1 user,  load average: 0.90, 0.67, 0.37
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
pi       pts/0    241-6.allergrupp 09:02    0.00s  1.91s  0.03s w

Has anyone experienced this?

  • Try adding sudo to the start of your commands, just in case it's a permissions issue.
    – recantha
    Mar 12, 2013 at 8:41
  • 3
    It's not a permissions issue. It may work coincidentally (but I doubt it) -- even so, it is not a permissions issue. Stuff is broken.
    – goldilocks
    Mar 12, 2013 at 8:45
  • No go running commands with sudo.
    – rebellion
    Mar 13, 2013 at 10:50
  • Install GDB + symbols, and get a backtrace, to see where it SIGSEGVs? Mar 14, 2013 at 22:15
  • If "segmentation fault" only occurs when running apt-get your card may not be corrupt. See my answer below.
    – NULL
    Mar 8, 2016 at 16:46

6 Answers 6


That's very unfortunate. Segmentation faults should not be happening like that, and it strongly implies to me you have filesystem corruption. It could also be the result of something malicious, but that is probably less likely on the pi since it is prone to such corruption if, eg, it is subject to inappropriate voltages, or frequently unplugged without a proper shutdown.

Take the SD card out, salvage whatever you want/can off it using another computer, then umount it there but leave it plugged in and try:

e2fsck -y -c /dev/[sdXN]

Where 'sdXN' is the second partition. That might fix things. If not, give up and replace the image on it -- it's wrecked.

After you replace the image, run the same slow fsck (with -c to check for bad blocks) on the 2nd partition while the card is in another computer. This is to make sure the card is not faulty or worn out.

  • This didn't help. What I now experience is that the SD card won't be formatted with either Mac, PC nor SD Formatter. Corrupt card maybe?
    – rebellion
    Aug 15, 2013 at 7:14

These kinds of issues are like trying chase a white Rabbit. You will waste a lot of time and never catch it. It sounds like the file system is corrupt. In my experience with Raspberry Pi Distros and the Pi is to make backups of your images. I take backups at critical points, so when this does happen, I can just re-image the SD card.

I have had too many cards or file systems become corrupt. A good work-around is to use a USB stick for the File System. Some useful info can be found here.

I personally think that using a SD card in inherently flawed. With no built in power switch to perform a safe shutdown you are almost guarantee to corrupt your file system. I know because it has happen to me a lot. I always do a "Safe Shutdown" and have had SD card break. The best you can do is use the USB as the file system and always backup your images :)

  • First link is dead. Nov 5, 2021 at 7:48
  • 1
    I delete the link as it’s no longer valid.
    – PhillyNJ
    Nov 5, 2021 at 10:33
  • Don't USB sticks also use flash memory, which is equally vulnerable to write cycles? Nov 5, 2021 at 23:19

This seems to be the result of filesystem corruption on the SD card. My two RPi-s have both experienced it, usually after either a lot of use over a short period (say, downloading torrents), or just after long uptimes. I haven't found any easy way to repair the damage, and have just reflashed images onto the cards.

Trying another power adapter is always a good idea, too.


Like all strange and semi-random errors on a Pi, this can also be caused by a power supply that doesn't deliver enough and/or stable power. Try a different model.


Can you confirm that you have enough space on the SD card, I think I saw this when I forgot to expand my rootfs after install. It fills up pretty quick after initial configuration and loading of packages. Do a df -k and make sure you are not at 100% on rootfs.


I know this is an old question but I had this problem with apt-get. If the segmentation fault only occurs when running apt-get this might help:

sudo rm -rf /var/cache/apt/*.bin

After running this command I was able to install packages again.

Not the answer you're looking for? Browse other questions tagged or ask your own question.