18

I'm trying to get the profile directory of the default firefox profile (the one that opens automatically) from Bash. How could I proceed? I can't find any useful options issuing firefox --help

3
  • you can du a firefox; sudo lsof | grep [username] | grep firefox | grep profile which would get a firefox instance running. lsof will show you the opened files; grep will filter you out the interesting parts of lsof. This will quickstart the info + needs some fine-tuning. What do you need the information for anyhow? Do you wanna put some stuff automatically in a firefox profile folder - why? Jan 10, 2013 at 13:22
  • I want to get the firefox decmod.db file, because it is needed for a Java web application. For some reason, it works out of the box on Windows, but a configuration file with the path to the decmod.db file should be placed at home on Linux. I want to generate this file automatically. Jan 10, 2013 at 16:17
  • Sorry, can't edit my previous comment. Your proposal "works", but I want to place this on a session start script (for several reasons, it's the only place that makes sense) and I don't want to run firefox on each session start. Jan 10, 2013 at 16:26

4 Answers 4

17

Try grep 'Path=' ~/.mozilla/firefox/profiles.ini | sed s/^Path=//. Default profile folder name is stored in profiles.ini. This will work fine while you've got single profile.
If you have more than one Firefox profile then the file format changes, so extracting the folder name becomes more tricky. Here's the script to do that:

#!/bin/bash

cd ~/.mozilla/firefox/
if [[ $(grep '\[Profile[^0]\]' profiles.ini) ]]
then PROFPATH=$(grep -E '^\[Profile|^Path|^Default' profiles.ini | grep -1 '^Default=1' | grep '^Path' | cut -c6-)
else PROFPATH=$(grep 'Path=' profiles.ini | sed 's/^Path=//')
fi

echo $PROFPATH

This script will work in both cases, it selects the appropriate method depending on the amount of profiles. Works in OSX, too.

10
  • Apparently now the default profile is the one in profiles.ini that has the line Default=1 and it can be anywhere in the file (first, middle, last).
    – Xen2050
    Mar 18, 2016 at 11:43
  • @Xen2050 Are you sure? I checked 2 different profiles from Ubuntu & Windows machines. Both have no Default=1 line. Both have [Profile0] section with Name=default in them instead. Can you provide your profiles.ini using paste.ubuntu.com ?
    – whtyger
    Mar 18, 2016 at 13:29
  • It's just got that one extra line, under the 2nd profile actually. I've changed my default profile using the profile manager, try using it too (with the -p option) and see if it changes on yours. There must be related info pages on mozilla.org, but I'm not able to search right now.
    – Xen2050
    Mar 18, 2016 at 21:41
  • Did find a link, mentions it along with don't ask/show profile manager & use last selected profile to change the default kb.mozillazine.org/Profiles.ini_file
    – Xen2050
    Mar 18, 2016 at 21:50
  • @Xen2050 Added script to process multi-profile profiles.ini.
    – whtyger
    Mar 20, 2016 at 6:23
7

Your default profile directory is stored under home directory.

cd ~/.mozilla/firefox 

Here you will find something like xxxxxxxx.default. This is the location where all your personal data is stored.

You can run the command firefox -P to show the profiles available and select one from the list.

4
  • The correct dir should be .mozilla
    – leorize
    Jan 10, 2013 at 13:39
  • 1
    That's what I'm doing right now, find $HOMEDIR/.mozilla/firefox/ -maxdepth 1 -type d -name *.default | head -1. But that CAN fail. It's not a good way to do it. Jan 10, 2013 at 16:33
  • @JorgeSuárezdeLis Could you explain in what scenarios this can fail? Not disagreeing, but I'd like to know. Apr 20, 2018 at 16:33
  • It will fail if the user has more than one profile and it is not using the one named whatever.default Apr 21, 2018 at 17:26
1

I know that this a little older, but in case someone else also needs this information, here is how I set the default profile variable in a wrapper script for firefox:

def_Pfile=`cat "$HOME/.mozilla/firefox/profiles.ini" | sed -n -e 's/^.*Path=//p' | head -n 1`

Hope this helps, as it works for me.

0

It works like a charm on linux.

My profile.ini

cat "$HOME/.mozilla/firefox/profiles.ini"                                         
[Install4F96D1932A9F858E]
Default=4hthy81n.default-release
Locked=1

[Profile1]
Name=default
IsRelative=1
Path=t6kac19e.default
Default=1

[Profile0]
Name=default-release
IsRelative=1
Path=4hthy81n.default-release

[General]
StartWithLastProfile=1
Version=2

So run this command:

grep "Default=.*\.default*" "$HOME/.mozilla/firefox/profiles.ini" | cut -d"=" -f2

about:profiles:

about:profiles

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .