Getting internet browsing history from shell

is it possible to use the shell or generate a shell script to find out the browsing history from the browsers installed on the system? thank you


Solution 1:

Example for Firefox:

The history can be found in a database table in places.sqlite in SQLite format 3:

$ file ~/.mozilla/firefox/rsbxl7fx.default/places.sqlite
~/.mozilla/firefox/rsbxl7fx.default/places.sqlite: SQLite 3.x database, user version 26
  • rsbxl7fx.default

    Depending on your profile

To view the history you need to install sqlite3:

sudo apt-get install sqlite3

Start sqlite3 with

sqlite3 ~/.mozilla/firefox/rsbxl7fx.default/places.sqlite

and list eg. all tables:

sqlite> .tables
moz_anno_attributes  moz_favicons         moz_items_annos    
moz_annos            moz_historyvisits    moz_keywords       
moz_bookmarks        moz_hosts            moz_places         
moz_bookmarks_roots  moz_inputhistory

Or the history with:

sqlite> SELECT datetime(a.visit_date/1000000,'unixepoch') AS visit_date, b.url FROM moz_historyvisits AS a JOIN moz_places AS b ON a.place_id=b.id WHERE 1 ORDER BY a.visit_date ASC;

Example for Chrome:

The History is a binary file in SQLite format 3:

$ file ~/.config/google-chrome-beta/Default/History           
.config/google-chrome-beta/Default/History: SQLite 3.x database
  • google-chrome-beta

    Depending on your version of Chrome

  • Default

    Depending on your profile

To query the database, Chrome must be completely closed. Or you have to create a copy of the file and use that copy.

To view the history you need to install sqlite3:

sudo apt-get install sqlite3

Start sqlite3 with

sqlite3 ~/.config/google-chrome-beta/Default/History

and list eg. all tables:

sqlite> .tables
downloads             meta                  urls                
downloads_url_chains  segment_usage         visit_source        
keyword_search_terms  segments              visits

or to see all URLs:

sqlite> SELECT * FROM urls WHERE 1;

For all examples; alternatively, a GUI may be used:

  • sqlitebrowser

    sudo apt-get install sqlitebrowser
    

    and start with:

    sqlitebrowser ~/.config/google-chrome-beta/Default/History
    sqlitebrowser ~/.mozilla/firefox/rsbxl7fx.default/places.sqlite
    
  • sqliteman

    sudo apt-get install sqliteman
    

    and start with:

    sqliteman ~/.config/google-chrome-beta/Default/History
    sqliteman ~/.mozilla/firefox/rsbxl7fx.default/places.sqlite
    

Solution 2:

As far as firefox goes, there is .mozilla/firefox/********.default/ directory , where ****** is some number unique to your install. For me that is qgided18.default . According to https://askubuntu.com/a/412890/295286 places.sqlite file is the one that contains browsing history. You can use cat to view files, but it will be gibberish mixed with text. For actually reading it, use A.B.'s suggestion on installing sqlitebrowser

Solution 3:

browser-history - external history of web browsers, such as netscape

The service must be added to startup scripts, and you may view the traffic recorded so far by viewing ~/.browser-history/history-log.html. However, this will not give you previous history.