Is it possible to create Firefox profiles via the command line? I need to programatically launch Firefox with different proxy settings. From my understanding, I can do this via creating a profile. However, I don't want to create these profiles manually.
2 Answers
You sure can!
example:
firefox -CreateProfile john
check out the rest of Firefox's command line arguments.
Once your profile is created and configured you can launch the profile by doing the following:
firefox -P john
- 65,321
The simple answer from 2010 (firefox -CreateProfile profile_name) doesn't work anymore in recent Firefox versions.
Credit to @Waylander in a comment to the old answer, he notes that you have to add some more arguments:
firefox -CreateProfile profile_name --headless --screenshot /dev/null
Indeed that works, also in Firefox Nightly (currently version 134.0a1).
Warning though - this will create a profile folder named random.profile_name where random are 8 random characters. I'm not aware of a way to get rid of this randomness, other than below.
So, if you'd like to create a profile at some exact path, you can:
just make a new folder in your Firefox profiles root folder, or anywhere else:
mkdir -p ~/.mozilla/firefox/profile_nameAdd correct entry to
~/.mozilla/firefox/profiles.iniin any way you'd like (script or not).[Profile#] Name=profile_name IsRelative=1 Path=profile_nameImportant:
#has to be a number which is next in sequence considering other profiles defined inprofiles.ini. If you make a mistake, your new profile will not be detected and so it won't even show up in the Profile Manager (firefox --ProfileManager).If you set
IsRelativeto0, then setPathto full absolute path to the profile folder.Create a
user.jsin your profile folder (e.g.~/.mozilla/firefox/profile_name/user.js), which enables you to configure your Firefox profile before the 1st launch.A lot can be achieved with
user.js, few examples below:- https://github.com/arkenfox/user.js/blob/master/user.js
- https://github.com/yokoffing/Betterfox/blob/main/user.js
If you're looking how to set some specific config value, you have to first know its key. If searching on the Internet doesn't work out, you can always run Firefox in your default profile, and study the values in
about:config. Then put the same key you found intouser.jswith the value you'd like. For example, to set HTTPS proxy port to 443:user_pref("network.proxy.ssl_port", 443);Launch your configured Firefox now with
firefox -P profile_name.
- 491