Paranoid's Guide to Bookmarking

Bookmark stuff and keep it private with Buku

Paranoid’s guide

Welcome to Paranoid’s Guide, a series of articles where I’ll show you how to live your life in this hyper tech-centric world without letting the nosy types out there peek into your sacred privacy. Maybe you have a good reason not to let powerful, abusive corporations get ahold of you personal information and keep you on an emotional leash that makes you feel like a slave of crushing, invisible hands. Maybe you’re just nuts. Either way, this is the series for you.

Bear in mind that we’ll rely entirely on the right-mindedness of open source developers—there’s no such thing as “Trust no one.” If you’re so paranoid you can’t trust even open source, then I recommend you code your own stuff from scratch. Just make sure you share it with us after, okay?

How it all began

I still remember how I used to manage bookmarks in the 2000s. It was easy enough on my desktop computer: I used to keep a text file with bulleted lists of links, organized by categories. Because I also used the computers at my University, I had to find a way of saving the results of the research I did on those machines. The solution I found, and that I’m not proud of, was to email myself all those links and, as soon as I got home, save them to my bookmarks.txt file. I can still see some of those links, mostly broken now, in my old Yahoo! inbox.

By 2008 I came across a bookmarking web service called del.icio.us. I’m not exaggerating when I say that del.icio.us completely changed the way I used the web—back then, I only used it for emailing and academic research. By that time, I had both a desktop and a laptop computer, and having my links in a centralized place made my life quite easier.

It didn’t take long for browsers to embed centralized bookmark managers in the form of web services. The first one I saw was Firefox’s. I used its bookmark manager for a while, but privacy had already become a keen subject to me by then, which is why I deleted both my Mozilla and del.icio.us accounts.

I was back to the same problem I had faced years before: how to keep all my bookmarks in one, easily accessible place. This time around, the solution was to use a pen drive that I’d carry with me everywhere. That worked for me for years, but sometime in 2016 I found a better way.

Enter Buku

Buku is a bookmark manager that you can install on your local machines and control from the command line. I won’t go over all the features and commands available, but the documentation is pretty thorough and should cover even the edge use cases. If you aren’t a command line person, you can try Bukuserver or a front end GUI.

How I use it

I usually install Buku (and its dependencies) with pip for Python 3:

pip3 install certifi urllib3 cryptography beautifulsoup4 buku

If you prefer using a package manager, you can find pre-packaged versions for a bunch of operating systems.

That will give you access to Buku through the command buku:

$ buku --version
3.5

This is how I add a bookmark:

$ buku \
--add https://github.com/jarun/Buku \
--title "Buku bookmarker" \
--comment "Awesome CLI bookmarker" \
--tag tools,software,foss
1139. Buku bookmarker
   > https://github.com/jarun/Buku
   + Awesome CLI bookmarker
   # foss,software,tools

You can use the short version of some of those options too (-a for addition, -c for comment and -t for tags). Note that not all options are mandatory; if you don’t specify a title, for instance, Buku will try to get it from the webpage you’re bookmarking.

This is how I search for bookmarks matching multiple tags (both tools and foss):

$ buku --stag tools + foss
1. How to check spelling at the Linux command line with Aspell | Opensource.com [1063]
   > https://opensource.com/article/18/2/how-check-spelling-linux-command-line-aspell
   # foss,linux,tools

2. Buku bookmarker [1139]
   > https://github.com/jarun/Buku
   + Awesome CLI bookmarker
   # foss,software,tools

The short option here is -t for tags.

Finally, this is how I delete a bookmark:

$ buku --delete 1139
Index 1139 deleted

You can also use -d instead of --delete.

That’s great, but we haven’t yet solved the problem I’ve been talking about since the beginning of the article: how to put all those bookmarks in one place and share them across different machines.

Centralizing the bookmarks

Buku stores its data in a SQLite3 file. If you’re a *nix user, I can already see the smile on your face. All we have to do is move the database file to a shared location (an NFS directory, a Dropbox folder, you name it) and create a soft link to it. In my case, I have a Nextcloud server set up in a LAN and all devices connected to the local network have access to it.

On Linux, Buku will create the SQLite3 file under ~/.local/share/buku/bookmarks.db. The first thing we need to do is move it to the shared location of our choice. Nextcloud clients by default create a Nextcloud directory under the user’s home folder, and that’s where I’ll move the SQLite3 file:

mv ~/.local/share/buku/bookmarks.db ~/Nextcloud/

We now have the database file at ~/Nextcloud/bookmarks.db, but Buku has no idea about it. We can easily fix that with a symlink:

ln -s ~/Nextcloud/bookmarks.db ~/.local/share/buku/bookmarks.db

That will create a symlink (~/.local/share/buku/bookmarks.db) that points to the shared database file at ~/Nextcloud/bookmarks.db.

On my other machines, as I soon as I install Buku, I go straight to step two (the ln -s part), because the database file is already being shared through Nextcloud.

If you use something like Dropbox, you can just replace ~/Nextcloud with the folder used by your Dropbox client. Note, though, that Dropbox is a public service, and it’s up to you to trust your private data with them or not. In those cases, I recommend you encrypt your Buku database before syncing with their servers.

Encryption

Because my Nextcloud server isn’t accessible from the Internet and I hardly ever use any computer that’s outside of my LAN, I don’t have to worry too much about this. If you want to keep your Buku database in Dropbox or similar services, though, you should consider encrypting the SQLite3 file before uploading or syncing it:

$ buku --lock
Password: ***
Password: ***
File encrypted

You’re safe to send the file to the Dropbox server now, but Buku throws an error if you try to use it:

$ buku --stag tools
[ERROR] Unlock database first

You’ll need to unlock Buku in order to access it again. Before decrypting the database, make sure you pause your Dropbox client. Then, and only then, unlock Buku and use it normally:

buku --unlock
buku --add [...]
buku --stag [...]
buku --delete [...]

Just don’t forget to lock it back before resuming yor Dropbox client.

/img/2018/08/2018-08-14-paranoids-guide-to-bookmarking/sharing-the-bookmarks.jpg

Sharing the bookmarks' database in Dropbox with encryption (in transit and at rest).

Conclusion

I hope I was able to show you that Buku is a great tool when it comes to privacy and ease of use. Buku is not only feature rich, but also non intrusive and light weight. And it was made with CLI users in mind! What not to like about it?