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).
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.
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.
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.
-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