Score:0

How can I free disk space in ubuntu?

de flag
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?

pasman pasmański avatar
mx flag
Welcome to AskUbuntu! Which release of Ubuntu you use ?
Avijit avatar
de flag
Ubuntu `20.04 LTS`
PonJar avatar
in flag
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/
Soren A avatar
mx flag
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.
Avijit avatar
de flag
`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?
karel avatar
sa flag
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)
Avijit avatar
de flag
@karel No, it's a different question.
karel avatar
sa flag
I'm going to leave it anyway because `/var` is maybe where the unneeded large files are located.
Avijit avatar
de flag
Ok thank you @karel
Score:0
ch flag

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.

Score:0
cn flag

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

`

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.