Bash – How to get bash tab completion to work with read only file system

autocompletebashhere-documentreadonly

I have deliberately configured the file system of my RaspberryPi (Raspbian – Jessie) to be read only. One of the things that's not (yet) working is tab (aka auto) completion in bash, where I often get the following error:

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

Much on-line discussion focuses on how to fix file system problems manifesting themselves with this error. I'd like to adjust bash instead. Where is it trying to create this temp file and how can I redirect it to create that file in /tmp (which is mounted with tmpfs)?

Best Answer

The first test you can do to see where is your tmp folder and if it is working is executing this command:

tempfile

The output should be something like this:

/tmp/fileupz962

If the folder /tmp exists and is working (has write permissions) but the temp folder is pointed to other directory like /var/tmp you can try to set the temp folder to point to /tmp using:

export TMPDIR=/tmp

If bash is saving the temporary file in /tmp and if for some reason the /tmp folder is not working you can try to unmount it (in case it is mounted). It may happen that the /tmp is mounted as read only. In both cases should be useful to try:

sudo umount /tmp

Then you can try using RAM storage for the /tmp directory:

sudo mount -t tmpfs -o size=128M tmpfs /tmp/ram/

You can set the amount of RAM (-o size=128M) to whatever value you want.

Related Question