1. Home
  2. Linux

How To Host A Personal Pastebin Alternative On Linux

Pastebin is a reliable tool for Linux users. With it, it’s very easy to share Bash scripts or even development code at the drop of a hat. Unfortunately, it’s not a private service, so anyone can see your stuff — unless you cough up some dough to protect it. It’s also not open source. If you need something that works like Pastebin but with privacy, minus the premium cost, you can host your own personal Pastebin alternative on a Linux server.

In this guide, we highly recommend setting up a special machine to run Ubuntu server. However, if you don’t have a server, consider following this guide on the Ubuntu desktop as all of the web server technology is available for installation and the PrivateBin software doesn’t require any special server-only configuration tools or special knowledge.

Note: though we focus on Ubuntu and Ubuntu server in this tutorial, any Linux server/desktop OS that supports LAMP will do.

LAMP Server

Most Pastebin alternatives that work on Linux are web applications. These tools need a complete set of web tools on a Linux server to even function. That’s why in this section of the guide, we’ll go over how to set up a LAMP stack.

What’s a LAMP stack? It’s Linux (in our case, Ubuntu Server), Apache2, MySQL, and PHP. Without these tools, there is no way to run the software in the guide.

Setting up a LAMP stack on Ubuntu is super easy. To do it, open up a terminal, remote in via SSH (if you need to) and run the following apt install command.

sudo apt install lamp-server^

Running the above command will grab virtually everything we need. When everything is done installing, we’ll need to install another tool. Specifically, we need the Git tool, so that it’s possible to interact with GitHub. To install, enter the command below.

sudo apt install git -y

Now that the Git tool is working, the installation process can start.

Install PrivateBin

Getting PrivateBin working is super easy as the software doesn’t use a traditional database method. Instead, all of the pastes and information is set up in a “flat file” structure. Not using something like MySQL might sound scary and inefficient, but it’s not. Going with a file-only setup means any user can easily set up this software. Better yet, since it skips SQL and traditional database setups, backup is as easy as saving the files.

To install PrivateBin, we’ll be interacting directly with its development page on GitHub. Going the GitHub route means that installing the software is as easy as running the git clone command in a terminal. In a terminal, use the CD command, move to the web directory and install PrivateBin with Git.

cd /var/www/html/

sudo -s

git clone https://github.com/PrivateBin/PrivateBin.git

Installing the PrivateBin software with a git clone is incredibly fast. At this point, if you open a web browser tab and enter the following URL into the address bar, you’ll be able to access it instantly.


or, if you installed it on Ubuntu desktop:


Leaving PrivateBin in the clone folder isn’t very good. For a better setup, consider moving it to the root /var/www/html/ directory.

Using the mv command, move all of the PrivateBin files to the right directory, and update all of the permissions.

cd /var/www/html/PrivateBin/

sudo mv * /var/www/html/

sudo chmod 777 -R /var/www/html/
sudo rm -rf PrivateBin

Access the new PrivateBin setup at:


or, if you installed it on Ubuntu desktop:



PrivateBin is a very simple tool. To use it, load up the website and paste some text in the “Editor” box. With the text in the Editor box, it’s time to set the format. Look to the top of the editor and select the drop-down next to “Format”.

Scroll through the menu and select an appropriate format for your paste. When everything looks good, click “Send” to get a shareable link for your paste.

Destructive Pastes

Did you know that PrivateBin can create destructible pastes that delete after being read? To use this feature, create a paste, and check the “Burn after reading” box.

After checking the self-destruct box, click the drop-down menu next to it and set the expiration date. When a user opens your “Burn after reading” paste, it will delete itself.

Backup PrivateBin

Creating a backup of PrivateBin starts by creating a Tar archive.

tar -czvf private-bin.tar.gz /var/www/html/

Encrypt the backup using GPG.

gpg -c private-bin.tar.gz

Finish the backup process by deleting the original archive.

sudo rm private-bin.tar.gz


Restoring your PrivateBin backup starts by moving private-bin.tar.gz.gpg into /var/www/html/.

sudo mv /path/to/private-bin.tar.gz.gpg /var/www/html/

Decrypt the file with GPG.

gpg -c private-bin.tar.gz.gpg

Extract the archive and move the backup into place.

tar -zvxf private-bin.tar.gz
cd html 

mv * ..
rm html
cd /var/www/html

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.