General-purpose free operating systems like Fedora, Debian, Ubuntu, Gentoo, FreeBSD, and OpenBSD are extremely customizable. You can slim them down or fatten them up as needed. However, they're much harder to slim down than they used to be, and far easier to fatten.
For most part, you'll need at least 500 MB of disk space just for the operating system, a Pentium II or equivalent CPU, and 32 MB of RAM if you don't run X Windows. 64 MB of RAM is a bare minimum if you run a lightweight window manager like TWM or IceWM; don't even try to run KDE or Gnome on less than 256 MB.
So when you want to hand-roll a nice firewall, print server, file server, router, or other specialized device that really doesn't need 500 MB of operating system, check out some of the many small, specialized Linuxes and BSDs. They fit on business-card CDs, compact flash cards, and USB keys. You even can carry one around on tiny portable media and have yourself a nice operating system no matter where you are.
There are hundreds of tiny Linuxes and BSDs. Here are a few to get you started.
Damn Small Linux: Damn Small Linux (DSL) weighs in at 50 MB. DSL comes with an amazing variety of useful applications in such a tiny package SSH, FTP, EmelFM (which is a very nice file manager), the GPhone VoIP softphone, and net-tools and other basic networking utilities. DSL is based on Debian, so installing new packages is as easy as running apt install [foo].
Feather Linux: Feather Linux weighs in closer to 128 MB. It comes with more networking tools than DSL, especially wireless utilities like dsniff, aircrack, and madwifi. It also has nmap, iptables, minicom, rdesktop, VNC viewer, LinNeighborhood, and other tools that make it the basis for a good network troubleshooting or fixing laptop.
m0n0wall: m0n0wall is a stripped-down (less than 6 MB) FreeBSD designed for building firewalls. Despite its tiny size, which makes it a perfect operating system for single-board computers, like the Soekris 45xx boards, it has an excellent graphical interface for configuration, management, and monitoring. If you want to build a good stout firewall with VPN, NAT, traffic shaping, and wireless support with a minimum of pain, m0n0wall is just the ticket.
FreeNAS: FreeNAS stands for "Free network-attached storage." FreeNAS, based on FreeBSD, occupies less than 16 MB, yet you can use it to build a fileserver that supports both *nix and Windows clients, has user authentication, supports software RAID, and has a graphical management interface. Just like m0n0wall, the Web GUI handles everything: configuration, management, and monitoring.
As these four examples show, you can get a lot of power in a tiny package.