I have a script (I call it dusort.sh
) I use to gauge which files are taking up the most space on my drive in a given folder. It essentially boils down to this:
#!/bin/bash
du --all --human-readable --max-depth=1 $1 | sort -h -r
I need to run the command with sudo
because otherwise du
cannot read certain directories (/
, docker volume directories, etc). Is there a way to make it so I can run this command without being prompted for my root user password every time I want to check file sizes?
I have tried changing the file ownership
sudo chown root:root dusort.sh
but that doesnt seem to affect things. The only way to run this command without getting Permission denied
warnings on files is like so:
sudo ./dusort.sh