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:
cd ~/.mozilla/firefox/*default/
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:
id@hms-borange:~$ cd ~/.mozilla/firefox/*default id@hms-borange:~/.mozilla/firefox/19xwzg4w.default$ sqlite3 places.sqlite "select id,title from moz_bookmarks where type=2"1| 2|Bookmarks Menu 3|Bookmarks Toolbar 4|Tags 5|Unsorted Bookmarks 12|Latest Headlines 15|Ubuntu and Free Software links 22|Mozilla Firefox 67| 70|All Bookmarks 194|e-dribble 2024|JOBS 3026|Nedroid Picture Diary 36522|The Register 49621|jubs 92363|maemoo id@hms-borange:~/.mozilla/firefox/19xwzg4w.default$ IDS=$( sqlite3 places.sqlite "select fk from moz_bookmarks where parent=92363" ) id@hms-borange:~/.mozilla/firefox/19xwzg4w.default$ for i in $IDS ; do sqlite3 places.sqlite "select url from moz_places where id=$i" ; done http://maemo.org/maemo_release_documentation/maemo4.1.x/node4.html#SECTION00432000000000000000 http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Platforms/Maemo/ http://maemo.org/development/sdks/maemo_2-2-gregale/ http://maemo.org/development/documentation/tutorials/Maemo_2_2_Tutorial/#settingup http://scratchbox.org/download/scratchbox-apophis/ http://repository.maemo.org/stable/gregale/ http://repository.maemo.org/stable/gregale/i386/ http://repository.maemo.org/stable/gregale/armel/