How to Fix “Tab completion errors: bash: cannot create temp file”?

In the Bash Shell, there exists a feature called tab completion. It is quite useful in such a way that when a user is typing the command, by pressing the “TAB” key, the command is automatically written. Some users reported facing the error “bash: cannot create temp file,” which can be fixed. It is usually caused when the number of inodes has reached the limit on the system. Now how to fix it?

This guide explains the Tab completion error: bash: cannot create a temp file and its possible fixes.

  • Understanding the Error bash: cannot create temp file.
  • Reason: Disk Running Out of Inodes
    • Solution 1: Delete Unused Files and Directory.
    • Solution 2: Clear the Whole /tmp 

Understanding the Error bash: cannot create temp file.

In a Linux system, when the total number of assigned Inodes reaches the limit, it causes the error “bash: cannot create temp file” when the “TAB” key is pressed for tab completion. It can also be held responsible for random system/application crashes, and many users have yet to learn this happens even though there is a lot of space left on the drive.

Reason: Disk Running Out of Inodes

When the number of Inodes runs out in the root file system, no more new files can be generated, and data loss can occur. Since almost every other script or program facilitates the exchange of data between the processes and files.

Solution 1: Delete Unused Files and directory.

First, list the contents of the /tmp file using this command:

$ ls /tmp

In the above image, we have added a file named “File1.zip” that is extra in this folder, to remove it, use this command:

$ rm /tmp/File1.zip

The above command removes File1.zip from the /tmp directory and in this way, remove all the unnecessary files and directories.

Solution 2: Clear the Whole /tmp Directory.

Use this fix only when Fix 1 has not worked for you, and make sure to back up all the important files from the /tmp directory before executing the rm command like this:

$ sudo rm -rf /tmp/*

The above command removes all the files and directories from the /tmp folder, which can be confirmed using this command:

$ ls /tmp

In the above image, no files and directories are displayed which means that the /tmp directory is empty and this should fix the problem.

Conclusion

The “Tab completion error: bash: cannot create temp file” is fixed by freeing up the occupied Inodes by deleting the unnecessary files and directories. Users can either delete only a few files or clear up the whole directory using the “rm” command. This guide explained the reason for the error “bash: cannot create temp file” and its fixes.