Poking around firefox's bookmarks store: places.sqlite
Today I wanted to retrieve some bookmarks that I made the other day on my home computer, from far away. Thankfully I can access my pooter over SSH, allowing me to poke around inside it on the command line.
Older versions of firefox stored bookmarks in XML files, which made it easy to rifle through them on the shell. Newfangled firefox uses sqlite files however, which makes accessing this data a bit harder.
Here’s some quick commands you can run to extract your precious URLs from firefox’s places.sqlite file.
You’ll need sqlite3:
sudo apt-get install sqlite3
First, cd into your firefox profile dir, where the places.sqlite file resides:
To gain a list of all bookmark folders in this profile, do this:
sqlite3 places.sqlite "select id,title from moz_bookmarks where type=2"
Choose the folder whose URLs you want to list, noting its ID from the left column of the output from above . Use this ID in the next query instead of 92363:
IDS=$( sqlite3 places.sqlite "select fk from moz_bookmarks where parent=92363" )
Finally, get the URL associated with each ID:
for i in $IDS ; do sqlite3 places.sqlite "select url from moz_places where id=$i" ; done
Now you should have a neat list of URLs. These can be opened in firefox by simply specifying them as arguments on the command line. (So add
firefox $( ... ) around the previous command).
Here’s how it looked for me: