brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: du --time shows when each folder was last touched

Linux
~/tips/tip-disk-du-time-last-modified

du -h -d1 --time --time-style=long-iso ~/Downloads | sort -h

Adds the date of the latest change to each folder in a du listing.

Size alone does not tell me whether a big folder still matters. A folder of 40 GB that nobody has touched for two years is a different cleanup candidate from one that changed this morning. GNU du can print that in the same listing.

Add --time to show the time of the last modification of any file in the directory or any of its subdirectories:

du -h -d1 --time --time-style=long-iso ~/Downloads | sort -h

You get the size, the date and the path, per directory. --time-style sets the format: full-iso, long-iso, iso or your own +FORMAT, which is interpreted like in date. I like long-iso because it sorts naturally and is short.

You can also choose which time to show with --time=WORD. The man page lists atime (or access or use) and ctime (or status) next to the default modification time.

The caveat is in the word any. The shown time is the newest of everything below that folder, so one small file that changed yesterday hides the fact that the other 39 GB is old. Treat the list as a place to start looking, not as a reason to delete.

Further reading: du(1) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link