bash: cannot create temp file for here-document: What to do when No space left on device is displayed

Error summary

When I pressed tab to move the directory with cd, I got the message bash: cannot create temp file for here-document: No space left on device many times. When I read English well, I found that it was full of discs, so I responded.

The environment is Ubuntu (18.04).

Correspondence

1. Check the total disk capacity

Calm down and check the disk space with the df command. By adding the -h option, the capacity is displayed in an easy-to-read state.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             16G     0   16G   0% /dev
tmpfs           3.2G  114M  3.1G   4% /run
/dev/sda2       219G  208G     0 100% /
tmpfs            16G  784K   16G   1% /dev/shm
(Omitted below

It is almost full with / dev / sda2 219G 208G 0 100% /, and it is necessary to reduce the capacity here.

2. Identify the cause file

Use the du command to see which files are larger, traversing the directories in order from the root directory. The command to use is as follows.

sudo du -sh *

If you simply type du, a huge file capacity will be displayed, and the capacity display is also difficult to understand. The above commands are supported by the following methods.

--Change capacity to readable with -h option --The -s option does not include subdirectories. --If there are files that cannot be accessed, use sudo so that you can check the file size. --By adding *, the size of the directory and files directly under the current directory is displayed (otherwise, the size of the current directory).

It is also possible to display in order of capacity by using sort. However, in this case, it did not sort correctly in my environment with -h, so I used the following command.

du -s * | sort -nr

Use -n to sort the numbers and -r to reverse the order so that the larger capacity comes first.

If you can identify a large file and confirm that it can be deleted, delete it and you are done.

bonus

You can also use head and sort together to sort a few lines in order from the largest file.

du |sort -nr | head -n 5

However, of course, if it is a large file, it is not possible to delete it immediately, so in the end I think that I will search for a directory file that can be deleted steadily.

reference

-What to do when the disk is full on Linux -[[Du] command-Display disk usage: Linux basic command Tips (59)-@IT](https://www.atmarkit.co.jp/ait/articles/1610/25/news016. html) -[[Sort] command-Sort text files line by line: Linux basic command Tips (63)-@IT](https://www.atmarkit.co.jp/ait/articles/1611/09/news020 .html)

Recommended Posts

bash: cannot create temp file for here-document: What to do when No space left on device is displayed
What to do when Japanese is not displayed on matplotlib
Install pip on Mavericks
Install pip / pip3 on Ubuntu
A story stuck with Memory Error and No space left on device on AWS EC2
Pip install --ugrade pip fails on Windows
Install Python on Windows + pip + virtualenv
Install pip on CentOS7. Also iPython.
Install easy_install and pip on windows
bash: cannot create temp file for here-document: What to do when No space left on device is displayed
scipy stumbles with pip install on python 2.7.8
Install python on xserver to use pip
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
[Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv
[For IT beginners] What to do when the rev command cannot be used with Git Bash
How to write what to do when an application is first displayed in Qt for Python with Designer
What to do when a warning message is displayed in pip list
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
What to do if abort is displayed when inputting camera video in OpenCV
What to do when [Errno 2] No such file or directory appears in Python
[Python] What to do when No module named'pyproj.datadir' appears when Exe is done with PyInstaller
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if Python IntelliSense is not displayed in VS Code on Windows
curl: (60) What to do when Issuer certificate is invalid.
What to do when gdal_merge creates a huge file
What to do when "cannot import name xxx" [Python]
pipenv shell is no longer available ... what to do?
What to do when there is no response due to Proxy setting in Python web scraping
What to do when no display name occurs when unittesting Python + Tkinter on Github Actions Memo
What to do when PyCharm font is strange or garbled
ImportError: No module What to do when you are told
What to do if you get the message "" ~ .pkg "is corrupted and cannot be opened" when installing wxPython on Mac OS X
What to do if Python doesn't work on Git for Windows
What to do when a video cannot be read by cv2.VideoCapture
What to do if the inode is exhausted on EC2 Linux
What to do if PyAudio cannot be installed on Python 3.7, 3.8, 3.9 on Windows
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
What to do when the value type is ambiguous in Python?
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
What to do when "Something is already running at port 8000" is displayed when the develop command of Gatsby is executed.