linux-server-tools/dirsize/README.md

44 lines
999 B
Markdown
Raw Permalink Normal View History

2023-10-27 11:04:08 +02:00
# dirsize
This tool will scan the current folder and then calculate the total size of each folder within the current folder. It can take some time depending on the size.
It is very useful when trying to work out what is taking up all the storage capacity on a server.
If you run it in / you will get some errors as some folders have objects that are not files or folders and thus cannot be measured. Just ignore them as they are not critical. Also note that some folders you will need root access to calculate them. Alternatively you can use sudo.
## Setup
Make the file executable by using...
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
chmod +x dirsize.sh
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
Then either as root copy it to the /usr/bin folder without the .sh extension...
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
cp dirsize.sh /usr/bin/dirsize
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
or using sudo
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
sudo cp dirsize.sh /usr/bin/dirsize
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
2023-10-27 11:06:39 +02:00
## Example usage
2023-10-27 11:04:08 +02:00
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00
root@zeevs:/var# dirsize
4.0K ./mail
32M ./spool
139M ./cache
349M ./lib
6.2M ./backups
959M ./log
4.0K ./opt
4.0K ./local
56K ./tmp
2023-10-27 11:06:39 +02:00
```
2023-10-27 11:04:08 +02:00