5

I want to save all URLs of opened windows of google chromium in different text files with command line. In order to do that, I would need to know where google chromium stores their current google chromium URLs in Ubuntu 16.04 LTS.

Even though I want to write the script for chromium, I have tried this recommendation for Firefox and it didn't work. I couldn't find the sessionstore.js file anywhere.

  • The file ~/.mozilla/firefox/*default/sessionstore.js is available when Firefox is closed. In case it is open check the file ~/.mozilla/firefox/*default/sessionstore-backups/recovery.js :: source. – pa4080 Oct 29 '17 at 16:07
4

We can find which are Chromium's directories within user's home directory in this way:

find $HOME -type d -name *mium -exec echo {} \;

The result should be:

/home/<user>/.config/chromium
/home/<user>/.cache/chromium

Within the directory /home/<user>/.config/chromium/Default we can find couple of files that could be useful:

$ ls -1t $HOME/.config/chromium/Default | grep -i 'tabs\|sess'

Current Tabs
Current Session
Session Storage
Last Tabs
Last Session

The problem is that, unlike Firefox's log files Chromium's log files are not in readable format and it is hard to separate the tab's history from the current URLs.


However, within my Current Session I have two open tabs:

  • https://askubuntu.com/questions/970546/location-of-url-of-opened-tabs-of-google-chromium-in-ubuntu - that I've opened by a bookmark.

  • https://www.facebook.com/ - that I've opened by a bookmark, but then I've to login and then clicked to the FB logo.

I was able to achieve correct result by this ugly command:

$ cat -e $HOME/.config/chromium/Default/'Current Session' | sed -e 's/\^@/\n/g' -e '/_\/chrome/d' | grep -Po '(http|https)://\K.*' | sort -u

askubuntu.com/questions/970546/location-of-url-of-opened-tabs-of-google-chromium-in-ubuntu
www.facebook.com/?ref=logo

But when I open another tab and browse inside for a while the output of the above command become more fuzzy:

$ cat -e $HOME/.config/chromium/Default/'Current Session' | sed -e 's/\^@/\n/g' -e '/_\/chrome/d' | grep -Po '(http|https)://\K.*' | sort -u

askubuntu.com/questions/970546/location-of-url-of-opened-tabs-of-google-chromium-in-ubuntu
spidersport.com/forum/
spidersport.com/forum/index.php?sid=59f48a87db485e3a321aedbf7de68e6a
spidersport.com/forum/login.php
spidersport.com/forum/login.php?sid=59f48a87db485e3a321aedbf7de68e6a
www.facebook.com/
www.facebook.com/login.php?login_attempt=1&lwv=111
www.facebook.com/?ref=logo
www.spidersport.com/

Yes, the result is correct, because URLs of my open tabs are listed within, but there are also presented URLs from the browsing history.

2
$ perl -nwle '$h{$_}++ for /http[[:print:]]+/g; END{print for sort keys %h;}' \
~/.config/chromium/Default/Current\ Session

is a reworked version of @pa4080's (that I was unable to simply add as a comment.)

  • Can you please explain this for those of us not very familiar with Perl? I want an unsorted list with the most recent showing at the end. In fact, ideally only the last one since I am primarily interested in the current URI. – Chiwda Feb 17 '20 at 1:15
  • @Chiwda then try $ perl -nwle '$x=$_ for /http[[:print:]]+/g; END{print $x;}' ~/.config/chromium/Default/Current\ Session ...Yes, hard to explain. – Dan Jacobson 積丹尼 Feb 19 '20 at 9:04
0

This command attempts to find HTTPS URLs associated with a current session of Chromium: Here I am finding unique strings containing the word https to get the history.

strings to read string in binary files, grep to find the strings with https in them and sort -u to print only their single occurence

strings $HOME/.config/chromium/Default/'Current Session' |grep https| sort -u
  • 1
    Welcome and thank you for your contribution. Please edit your answer to explain what each part does and how that answers the question. (Also see How to Answer) – guntbert Dec 25 '19 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.