If you use or develop software, you will inevitably run into problems. When these problems arise, you end up needing to share error messages, command output or the contents of files with people online. An online content-sharing tool is often called a pastebin. Luckily within the Fedora ecosystem, we have our own tool to do just that: fpaste. fpaste is both a web-based pastebin and a command line tool. fpaste is a lifesaver for debugging errors or simply looking for feedback on some text.
How do you get access to fpaste? There are two methods; first we’ll look at the website.
To get started with fpaste, just go to the fpaste.org website, copy your error, paste it into the input box, and hit submit. The resulting page has the URL you can send to your fellow debuggers. The web user interface has options that allow you to:
- set the syntax of the paste,
- tag the paste with your alias,
- mark it private (including requiring a password), and
- set a self-destruct timer on the paste.
While the website’s great, the command line tool is where the real awesome lives. It makes it trivial to paste files or output from a command. It’s an extremely valuable tool for troubleshooting and reviews. First off, let’s get it installed. Use this command:
sudo dnf install fpaste
Once it’s installed, try pasting something!
echo "This is a test paste." > ./testpaste.txt fpaste testpaste.txt
After that, fpaste presents you with two URLs, one short and one long. The short URL is great for something like Twitter, but I tend to use the long one for everything else. Remember all the great options you were presented with in the web UI? The local client provides access to all the same features.
Want to password protect your paste?
fpaste testpaste.txt -d "my super secret password"
If you want to see all the options fpaste has to offer, check the man page.
fpaste your output
While pasting files is nice, sometimes the stuff you need to paste isn’t a file, but output from a command. Luckily, fpaste handles redirected output really well.
What are output redirects, you ask? Output redirects allow you to use the output of one command as the input to another. For example:
ls / | grep home
The command ls lists all the directories in a location. Grep searches through input and returns lines that match what you’re searching for. So, the above command will return home, since it was a match. The “|” operator is known as the “pipe.” It allows you to “pipe” output from one command to another. Suppose you want to find out what graphic card your machine has. You can run:
lspci | grep VGA
You should see some output similar to:
01:00.0 VGA compatible controller: NVIDIA Corporation GM206 [GeForce GTX 960] (rev a1)
Although this output is small enough you could easily just paste it directly into IRC, you could easily pipe this output to fpaste.
lspci | grep VGA | fpaste
This would then send that output to the Fedora pastebin. Neat, right?
But what if I need to paste a lot of info about my machine, you say? There’s a flag for that!
This will paste a broad overview of the current state of your system. Everything from the hardware you have to the top 5 CPU hogging processes will show up in this paste – which is really helpful for debugging whatever issues you might be having. You can use fpaste anywhere you might be looking for help: ask.fedoraproject.org, reddit, stackexchange, email, IM or IRC.
fpaste all the data
Some commands or utilities might still send some output to the terminal. This is often because the command is producing both standard output, or stdout, and standard error, or stderr. These outputs are often separated to allow sending useful data to one place, and logs or error messages to another.
If you want to paste the output of the command and be 100% certain you captured all the output (from stdout and stderr), use the “|&” operator. This operator takes all the stderr info and adds it to the generic stdout output, ensuring you can paste every last bit of debug information you need. There’s a lot you can do with output redirection. Check out this bash scripting tutorial to get ideas for what you can do.
Hopefully this short tutorial helps you out in the future. As a member of the QA team, I use fpaste numerous times a day. If you’ve never used fpaste before, take some time to experiment with it. For those of you who use fpaste, please mention how you use it in the comments. It’d be great to see all the ways the Fedora community uses this awesome tool!