The programs listed here are provided as exhibitions of just how compressed a Linux ELF executable can be and still perform a function. All of them abuse the kernel's casual approach to validating ELF files in order to reduce size. The assembler source code of each of these programs includes details showing how the ELF header, the program segment header table, and the x86 instructions of the actual program overlap each other.
In order to use one of these programs, you can download the assembler source and build it with nasm. If you don't want to install nasm, and you have reason to believe that I can be trusted, you can download a pre-built binary and run it directly. (Note that you will need to use chmod +x to mark a downloaded binary as executable.)
Despite the name, this program provides binaries for both true and false. It returns an exit code of either zero or one, depending on whether it is invoked with the name "true" or "false", respectively. At 45 bytes, this program is the smallest it is possible for a Linux ELF executable to be.
Here's a program that I've actually used. It simply runs forever, printing a bell character every four minutes or so. When I used it, I would leave it running in the background after logging into a remote machine that times out connections when they're idle. One can then disable the terminal's bell to make the character completely invisible. Admittedly, it's a bit longer than the one-line shell script I originally used, but on the plus side it doesn't take up an extra process in order to sleep.
Here is the program that started me off on this whole pursuit: hello world. It is dense. With the program header table overlaid on top of the ELF header, and program itself running through both of them, some of the bytes have no less than three different purposes.
Here you can find an even smaller hello-world program, apparently written by someone named Kikuyan (菊やん). It is only 58 bytes long, and would have been 57 if the author had used the same version of the greeting as myself. The program uses the technique of loading to absolute address zero, which permits a number of tricks that further reduce code size. I have not used this technique myself, because sadly current versions of Linux do not permit executables to use a load address of zero. It is an ingenious little program, though.
Brainfuck is a very simplistic programming language, which was invented by Urban Müller solely for the purpose of being able to create a compiler that was less than 256 bytes in size, for the Amiga OS. (More information about Brainfuck can be found at my Brainfuck page.) I eventually decided to take up the challenge as well, and create a Brainfuck compiler for Linux using less than 256 bytes. The compiler works as a filter: redirect the source code to the compiler's input and the compiler's output to a file. (And don't forget to chmod +x the output file.) At the beginning I didn't expect that I would actually succeed, since I thought I would need almost half of that just for the headers. I think my first cut was 458 bytes in size. I was quite pleased with myself when I trimmed that down to less than 300 bytes, ecstatic when I finally reached the 255-byte goal, and downright triumphant when I later got it to work in 238 bytes. By the time I had a 198-byte version, I had to admit that I had no idea where it was going to end. It's now at 166 bytes. And though I can't quite believe it, it works just as well as the first one did. As useless as it is, I think this one would have to be the crown jewel of my collection. It is quite possibly also the ugliest and most opaque program I have ever written.