I don't know why suddenly the following message has started to appear.

-bash: cannot create temp file for here-document: Read-only file system

I can't write files, only read, can't use tab to end the word...

I'm really newbie and I don't know what can I do, can somebody help me please?

  • 1
    What command do you execute when the error message occurs? Where do you use tab to end the word? On the command line?
    – Ingo
    Aug 2 '20 at 17:59

A quick search using the error message in your question was not particularly helpful, but a couple of things come to mind:

  • /tmp is corrupt/mangled

  • your SD card has failed & needs replacement

Here are some things to try. If none of them resolve the issue, I would suggest you try replacing your SD card.

1. sudo reboot

I guess you will have tried this by now, but just in case...

2. verify /tmp has permissions drwxrwxrwt

$ ls -ld /tmp
drwxrwxrwt   9 root root  4096 Aug 30 06:18 tmp

If they are different than this, set them correctly:

$ sudo chmod a+rwxt /tmp

3. check your /etc/fstab & verify / is properly mounted

$ cat /etc/fstab

The 2nd or third line should look like this (excepting the PARTUUID code):

PARTUUID=6c586e13-02 / ext4 defaults,noatime 0 1

4. run fsck on your unmounted file system:

fsck should be run only on an unmounted file system. If you have another RPi or Linux system, you can remove your SD card, plug it into this other system, and run fsck on it.

If you don't have another system - or simply want to do the enire process on your RPi - you can try this procedure to run fsck on your RPi.

5. replace µSD card

Again, if none of these steps has resolved your issue, you may find that replacing your µSD card is required. If you wish to back up your system before trying this, I'd suggest using the image-utils package for this.


There are different reasons why a file system can suddenly become read-only. However, the most important reason is that there are errors on the filesystem.

If you have screen & keyboard on the Pi, you may try to reboot. During the boot, fsck, file system check, will run and will give you (probably) a number of errors, which may (or may not) be possible to repair.

If you have a second Linux system (possibly via a live-USB version), you can try to do the fsck via that second system.

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