Saturday, November 21, 2009

Listing the size of directories

By doing ls -l, you won't get the size of directories. It will only be listed as 4.0K, while the files are listed correctly. But even the files are actually not listed correctly if you are currently changing the file, for instance during a download. It will list the final size of the file, not the current file size.

If you instead use the 'du' (disk usage) command, you will get a more correct number, even for directories.
du -sh *
will list all the files and directories in the current folder, with the size it occupies on the disk.

Listing which kernel modules you have built

Every now and then I'm confused about which modules I actually have compiled. And what was the name of that module you just built to fix your lm_sensors or wifi-card. This problem is not as common as it used to be, since a lot of software now seems to load the modules it needs, or even the kernel does it itself. But it's always good to have a clue I guess.

A little handy command to run is:
find /lib/modules/$(uname -r)/ -type f -iname '*.o' -or -iname '*.ko'
This will list all the modules in your module directory for the currently running kernel.