Two dumb tips that could save you a lot of time.

With a given directory/path, know in which device the data is stored

Sometimes you are in a machine with different block devices. Each one mounted in different mount points like /var/log /var/lib/mysql /mnt/backups, etc, etc.... For knowing where a file is stored you just execute something like:

$ df -h                                                              
~  
Filesystem                      Size  Used Avail Use% Mounted on  
/dev/mapper/group-volume_crypt  118G   85G   30G  75% /  
udev                             10M     0   10M   0% /dev  
tmpfs                           579M  852K  578M   1% /run  
tmpfs                           5.0M     0  5.0M   0% /run/lock  
tmpfs                           1.2G  776K  1.2G   1% /run/shm  
/dev/sda1                       232M   91M  126M  42% /boot

And then you try to match your directory with the entries. This is fucking WRONG!!!

If you want to know where the file /boot/grub/locale/ca.mo is stored just ask for that:

$ df /boot/grub/locale/ca.mo                                         
~  
Filesystem     1K-blocks  Used Available Use% Mounted on  
/dev/sda1         236876 92186    128153  42% /boot

Easy, right? You probably didn't know that one. I didn't either until I found a machine with like 12 mount points in similar paths and it was driving me crazy.

With a given IP, know which route will be used

This is another one I would loved to know years ago. When you have an IP and you want to know which route will use (or which interface, or which gateway, or which you-name-it) you probably are doing:

$ ip route  
default via 192.168.0.1 dev wlan0  proto static  
default dev eth0  scope link  metric 1002  
169.254.0.0/16 dev eth0  proto kernel  scope link  src 169.254.9.66  
169.254.0.0/16 dev wlan0  scope link  metric 1000  
192.168.0.0/24 dev wlan0  proto kernel  scope link  src 192.168.0.10

(Because you are using the "ip" command and not the old "/sbin/route -n", right?)

Anyway, if you have 8 routes, or 10, or 100 with different masks, etc, and you want to know which route is being used... you know... you can do it by your own trying to match the correct rule. This is good for you, for your brain cells and for remembering all the networking stuff you learned and  suddenly realize you don't remember anymore. Instead of doing all this fucking calculations by yourself, what about letting the computer to do the hard job for you? Lets say you want to reach the 192.168.0.200 host.

ip route get 192.168.0.200
192.168.0.200 dev wlan0  src 192.168.0.10 cache

And here we go!!! A beautiful line with the network interface and source IP  we would use, too. Pretty awesome and time saving, isn't it?

Extra bonus track. Sorting human-friendly-like.

When you are trying to know which file/directory is using more space you probably are executing:

$ du -shc music/*

69M     !!!  
14M     00 - Rain Storm - 15min.mp3  
849M    16bit Discography  
361M    2manydys  
48M     A.C. Newman  
340M    Air  
120M    Amon Tobin - Foley Room  
52M     Ana Tur Summer Memories.mp3  
[...]  
29G    total

But this is not useful since we are trying to find the biggest file. We could use this command for sorting the output numerically:

$ du -sc music/*  | sort -n  # --numeric-sort

[...]

832500    music/ST GERMAIN - From Detroit to St Germain 2CD 1999  
868964    music/16bit Discography  
1104460    music/radio  
1288768    music/seleccion34  
1819876    music/ibiza  
1899444    music/MusicSessions  
3745492    music/joanmarti  
30337056    total

But with this one you must convert the numbers to KB/MB/GB, etc... and it's kind of annoying. We can use this other one instead and we'll sort the output using human-friendly sort:

$ du -shc music/* | sort -h    # --human-numeric-sort[...]

813M    music/ST GERMAIN - From Detroit to St Germain 2CD 1999  
849M    music/16bit Discography  
1.1G    music/radio  
1.3G    music/seleccion34  
1.8G    music/ibiza  
1.9G    music/MusicSessions  
3.6G    music/joanmarti  
29G    tota

And this is it for today. Take care.