How do you empty the buffers and cache on a linux system

free && sync && echo 3 > /proc/sys/vm/drop_caches && free

You can signal the Linux Kernel to drop various aspects of cached items by changing the numeric argument to the above command.

To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
# echo 3 > /proc/sys/vm/drop_caches

The above are meant to be run as root. If you're trying to do them using sudo then you'll need to change the syntax slightly to something like these: