Termbin - Netcat-based command line pastebin

Termbin - Netcat-based command line pastebin

Today we will learn how we can share the output of a command from our terminal using nothing but netcat.

What is pastebin?

A pastebin or text storage site is a type of online content-hosting service where users can store plain text (e.g. source code snippets for code review via Internet Relay Chat (IRC)) Source: Wikipedia

How to use termbin?

Using termbin is really simple. As you head over to https://termbin.com/ you will see:


echo just testing! | nc termbin.com 9999 cat ~/some_file.txt | nc termbin.com 9999 ls -la | nc termbin.com 9999

So the format is: command | nc termbin.com 9999

When "command" executes, "|" will redirect its output to "termbin.com" on port "9999" via "nc" (netcat).

Installing netcat

Most linux distributions come with netcat preinstalled, for in case you're using Termux or a linux distribution which doesn't come with netcat preinstalled then you can install it using yourm package manager. On Debian/Ubuntu: sudo apt-get install netcat On Fedora sudo dnf install nc On Arch Linux: sudo pacman -S gnu-netcat


Let's try to create a termbin of manpage of netcat. man nc | nc termbin.com 9999 Output: https://termbin.com/sln3


For more ease, you can also create an alias of the command and simply pipe the output to it. echo 'alias tb="nc termbin.com 9999"' >> .bashrc Then to use it, simply type: command | tb

Now you can share the above URL with anyone you like, post it on a forum asking for help with an error, or sharing your code with your colleagues.