1
sudo du -h --max-depth=1


72K ./root
4.0K    ./cdrom
16G ./var
4.0K    ./media
5.9G    ./usr
146M    ./boot
12M ./etc
148K    ./tmp
13G ./home
16K ./opt
du: cannot access './run/user/1000/doc': Permission denied
du: cannot access './run/user/1000/gvfs': Permission denied
1.6M    ./run
4.0K    ./srv
4.8G    ./snap
16K ./lost+found
4.0K    ./mnt
0   ./dev
0   ./sys
du: cannot access './proc/9684/task/9684/fd/3': No such file or directory
du: cannot access './proc/9684/task/9684/fdinfo/3': No such file or directory
du: cannot access './proc/9684/fd/4': No such file or directory
du: cannot access './proc/9684/fdinfo/4': No such file or directory
0   ./proc
41G .

Which flies can I delete to free up disk space?

Avijit
  • 11
  • 2
  • Welcome to AskUbuntu! Which release of Ubuntu you use ? – pasman pasmański Nov 27 '21 at 07:51
  • Ubuntu `20.04 LTS` – Avijit Nov 27 '21 at 08:08
  • You can delete stuff in your /home/youruser/ folder but not the hidden folders within it. You can uninstall apps and snaps. You can search for tutorials about how to free up space such as this one https://itsfoss.com/free-up-space-ubuntu-linux/ – PonJar Nov 27 '21 at 08:18
  • The largest directories you have are ´7var` and `/home` at 12G and 16G.Look into thes and see what large file and directories there are. In /var it is typical /var/log. Find out what logs that grows and the errors that makes them grow- Fix the errors and delete the old versions of the log-files - typically there are 3 to 5 versions of each logfile. – Soren A Nov 27 '21 at 08:27
  • `1.3G ./.local/share/Trash/expunged/2726609749/rootfs 1.3G ./.local/share/Trash/expunged/2726609749 9.6G ./.local/share/Trash/expunged` Can I delete all of them? – Avijit Nov 27 '21 at 08:49
  • Does this answer your question? [Very large log files, what should I do?](https://askubuntu.com/questions/515146/very-large-log-files-what-should-i-do) – karel Nov 27 '21 at 12:22
  • @karel No, it's a different question. – Avijit Nov 27 '21 at 12:52
  • I'm going to leave it anyway because `/var` is maybe where the unneeded large files are located. – karel Nov 27 '21 at 12:55
  • Ok thank you @karel – Avijit Nov 28 '21 at 06:40

2 Answers2

0

There's a number of things you can do:

  • Install BleachBit: deletes unnecessary files.
  • Remove old revisions of snaps.
  • Check further options in Ask Ubuntu.

Here's the code that you need to put in a shell script and run (2nd option):

#!/bin/bash
# Removes old revisions of snaps
# close all snaps before running this!!
     
set -eu
LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
    snap remove "$snapname" --revision="$revision"
done
alper
  • 232
  • 5
  • 21
mike mcleod
  • 156
  • 1
  • 7
0

Maybe this will help some people. I just ran $ docker system prune -a on my work laptop and personal laptop and it cleared, respectively, 75 Gb and 50 Gb of disk space. Lots of Docker stuff hanging around apparently even though if I ran $ docker ps -a there was nothing there.