Working Ninja
2018-10-31T20:14:58
Simple Bash Shell Wrapper

Here's a simple shell wrapper that prints all sockets opened by Firefox.

1. Add the following function to your ~/.bashrc:

function ffsocks() {
    netstat -anp --inet | awk '/firefox/ { print $5 }'
}

2. Reload your shell (or run source ~/.bashrc) to make ffsocks callable from your shell environment.

3. Finally, execute ffsocks!

$ ffsocks
8.8.8.8:443
8.8.4.4:80

The power of shell wrappers comes from their ability to "codify" a more complex command (or series of commands, what flags are used, etc) and also in their reusable nature (we can call ffsocks any time we want!). Thus, shell wrappers are a good option for complex commands that are called often (or for those hard to remember ones that you don't call too often--I guess they're just all around good to use whenever!).