Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Weitere Informationen

Linux/Ubuntu and Windows: creating firefox profile for different users from command line

  • 10 Antworten
  • 5 haben dieses Problem
  • 1 Aufruf
  • Letzte Antwort von erotavlas

more options

Hi, I would like to create from command line by using the administrator user of a system the same firefox profile with plugin and customization for each user of the same system. I cannot use sync feature for this purpose.

I know from here edit https://developer.mozilla.org/en-US/...d_Line_Options https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options ~J99that the correct syntax is the following firefox -CreateProfile "JoelUser c:\internet\joelusers-moz-profile". On Linux/Ubuntu the following piece of code allows to create a profile for the sudo user


user=$(sudo logname)
firefoxProfile="/home/$user/.mozilla/firefox"
if [ ! -d "$firefoxProfile/m4v6pi7q.profile" ]; then
    rm -rf $firefoxProfile
    firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile"
        
    7z x -y ./m4v6pi7q.profile.7z
    mv ./m4v6pi7q.profile/* "$firefoxProfile/m4v6pi7q.profile"
    sudo chown -R $user:$user "/home/$user/.mozilla/"
    rm -rf m4v6pi7q.profile.7z m4v6pi7q.profile
fi

On Windows the following piece of code allows to create a profile for the administrator user


$ProgramsPath=${env:ProgramFiles}
$FirefoxProfile="$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\Profiles\u9w6vbcj.profile"
if(-Not (Test-Path $FirefoxProfile))
{
	$LocalProfile="$env:USERPROFILE\AppData\Local\Mozilla\Firefox\Profiles\*"
	if(Test-Path $LocalProfile)
	{
		Remove-Item $LocalProfile -recurse
	}
	
	$RoamingProfile="$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\Profiles\*"
	if(Test-Path $RoamingProfile)
	{
		Remove-Item $RoamingProfile -recurse
		Remove-Item "$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\profiles.ini"
	}
	& "$ProgramsPath\Mozilla Firefox\firefox.exe" -CreateProfile "profile $FirefoxProfile"

	& "$ProgramsPath\7-Zip\7z.exe" x -y .\u9w6vbcj.profile.7z
	move .\u9w6vbcj.profile\* $FirefoxProfile -force
	Remove-Item .\u9w6vbcj.profile.7z
	Remove-Item .\u9w6vbcj.profile
}

How can I create firefox profiles from a sudo/administrator user for each user (sudo/administrator and not sudo/administrator) of the system? On Linux/Ubuntu I tried with this code


usersList=$(getent passwd | grep -vE '(nologin|false)$' | \
awk -F: -v min=`awk '/^UID_MIN/ {print $2}' /etc/login.defs` \
-v max=`awk '/^UID_MAX/ {print $2}' /etc/login.defs` \
'{if(($3 >= min)&&($3 <= max)) print $1}' | \
sort -u)

for systemUser in $usersList; do
    echo $systemUser

    firefoxProfile="/home/$systemUser/.mozilla/firefox"
    firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile"
    7z x -y ./m4v6pi7q.profile.7z
    mv ./m4v6pi7q.profile/* "$firefoxProfile/m4v6pi7q.profile"
    chown -R $systemUser:$systemUser "/home/$systemUser/.mozilla/"
    rm -rf m4v6pi7q.profile.7z m4v6pi7q.profile
    
done

but it does not work and this is the output


sudo ./user.sh 
foo
Success: created profile 'profile /home/foo/.mozilla/firefox/m4v6pi7q.profile' at '/home/foo/.mozilla/firefox/m4v6pi7q.profile/prefs.js'
admin
Success: created profile 'profile /home/admin/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin/.mozilla/firefox/m4v6pi7q.profile/prefs.js'
jack
Success: created profile 'profile /home/jack/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin/.mozilla/firefox/m4v6pi7q.profile/prefs.js'
chown: cannot access ‘/home/jack/.mozilla/’: No such file or directory
zorro
Success: created profile 'profile /home/zorro/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin/.mozilla/firefox/m4v6pi7q.profile/prefs.js'
chown: cannot access ‘/home/zorro/.mozilla/’: No such file or directory

Why for the first two users is the directory for profile corretly set, while for the other is the directory of the user that executes the script /home/admin/.mozilla/firefox/m4v6pi7q.profile? I'm sorry for my very long question. Thank you


edit fixed link ~J99

Hi, I would like to create from command line by using the administrator user of a system the same firefox profile with plugin and customization for each user of the same system. I cannot use sync feature for this purpose. I know from here ''edit''<s> https://developer.mozilla.org/en-US/...d_Line_Options </s> '' https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options ~J99''that the correct syntax is the following firefox -CreateProfile "JoelUser c:\internet\joelusers-moz-profile". On Linux/Ubuntu the following piece of code allows to create a profile for the sudo user <pre><code> user=$(sudo logname) firefoxProfile="/home/$user/.mozilla/firefox" if [ ! -d "$firefoxProfile/m4v6pi7q.profile" ]; then rm -rf $firefoxProfile firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile" 7z x -y ./m4v6pi7q.profile.7z mv ./m4v6pi7q.profile/* "$firefoxProfile/m4v6pi7q.profile" sudo chown -R $user:$user "/home/$user/.mozilla/" rm -rf m4v6pi7q.profile.7z m4v6pi7q.profile fi </code></pre> On Windows the following piece of code allows to create a profile for the administrator user <pre><code> $ProgramsPath=${env:ProgramFiles} $FirefoxProfile="$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\Profiles\u9w6vbcj.profile" if(-Not (Test-Path $FirefoxProfile)) { $LocalProfile="$env:USERPROFILE\AppData\Local\Mozilla\Firefox\Profiles\*" if(Test-Path $LocalProfile) { Remove-Item $LocalProfile -recurse } $RoamingProfile="$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\Profiles\*" if(Test-Path $RoamingProfile) { Remove-Item $RoamingProfile -recurse Remove-Item "$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\profiles.ini" } & "$ProgramsPath\Mozilla Firefox\firefox.exe" -CreateProfile "profile $FirefoxProfile" & "$ProgramsPath\7-Zip\7z.exe" x -y .\u9w6vbcj.profile.7z move .\u9w6vbcj.profile\* $FirefoxProfile -force Remove-Item .\u9w6vbcj.profile.7z Remove-Item .\u9w6vbcj.profile } </code></pre> How can I create firefox profiles from a sudo/administrator user for each user (sudo/administrator and not sudo/administrator) of the system? On Linux/Ubuntu I tried with this code <pre><code> usersList=$(getent passwd | grep -vE '(nologin|false)$' | \ awk -F: -v min=`awk '/^UID_MIN/ {print $2}' /etc/login.defs` \ -v max=`awk '/^UID_MAX/ {print $2}' /etc/login.defs` \ '{if(($3 >= min)&&($3 <= max)) print $1}' | \ sort -u) for systemUser in $usersList; do echo $systemUser firefoxProfile="/home/$systemUser/.mozilla/firefox" firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile" 7z x -y ./m4v6pi7q.profile.7z mv ./m4v6pi7q.profile/* "$firefoxProfile/m4v6pi7q.profile" chown -R $systemUser:$systemUser "/home/$systemUser/.mozilla/" rm -rf m4v6pi7q.profile.7z m4v6pi7q.profile done </code></pre> but it does not work and this is the output <pre><code> sudo ./user.sh foo Success: created profile 'profile /home/foo/.mozilla/firefox/m4v6pi7q.profile' at '/home/foo/.mozilla/firefox/m4v6pi7q.profile/prefs.js' admin Success: created profile 'profile /home/admin/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin/.mozilla/firefox/m4v6pi7q.profile/prefs.js' jack Success: created profile 'profile /home/jack/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin/.mozilla/firefox/m4v6pi7q.profile/prefs.js' chown: cannot access ‘/home/jack/.mozilla/’: No such file or directory zorro Success: created profile 'profile /home/zorro/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin/.mozilla/firefox/m4v6pi7q.profile/prefs.js' chown: cannot access ‘/home/zorro/.mozilla/’: No such file or directory </code></pre> Why for the first two users is the directory for profile corretly set, while for the other is the directory of the user that executes the script /home/admin/.mozilla/firefox/m4v6pi7q.profile? I'm sorry for my very long question. Thank you ------- edit fixed link ~J99

Geändert am von John99

Ausgewählte Lösung

Hi, I solved with a brilliant idea. Since I need to install in many PC the same firefox profile and these PC should have only this profile, I can avoid to use the command firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile that is the source of the problem. I can directly move the firefox folder with profiles.ini inside plus the m4v6pi7q.profile and crash reports folders into the home folder of each user in the system. This works perfectly. I report the Linux/Ubuntu script


usersList=$(getent passwd | grep -vE '(nologin|false)$' | \
awk -F: -v min=`awk '/^UID_MIN/ {print $2}' /etc/login.defs` \
-v max=`awk '/^UID_MAX/ {print $2}' /etc/login.defs` \
'{if(($3 >= min)&&($3 <= max)) print $1}' | \
sort -u)

for systemUser in $usersList; do
	firefoxProfile="/home/$systemUser/.mozilla"
	if [ ! -d "$firefoxProfile/firefox/m4v6pi7q.profile" ]; then
		echo "Installing Firefox profile for user: $systemUser"
		sudo rm -rf $firefoxProfile
		sudo mkdir -p $firefoxProfile
		7z x -y ./firefox-profile.7z > /dev/null | egrep "p7zip|Ok"
		sudo mv ./firefox "$firefoxProfile/firefox"
		sudo chown -R $systemUser:$systemUser $firefoxProfile
		rm -rf firefox-profile.7z
	fi
done

and Windows script

$UsersList=(Get-WmiObject -Class Win32_UserAccount -filter "LocalAccount = True" | Select name)
ForEach($SystemUser in $UsersList)  
{ 
	$SystemUser=$systemUser.name
	# CompareTo returns 0 if strings are equal
	if($SystemUser.CompareTo("Administrator") -and $SystemUser.CompareTo("Guest") -and $SystemUser.CompareTo("HomeGroupUser$" ) -and $SystemUser.CompareTo("DefaultAccount"))
	{
		$UserPath="C:\Users\$systemUser"
		$FirefoxProfile="$UserPath\AppData\Roaming\Mozilla"
		if(-Not (Test-Path "$FirefoxProfile\Firefox\Profiles\u9w6vbcj.profile"))
		{
			Write-Host "Installing Firefox profile for user: $SystemUser"
			$LocalProfile="$UserPath\AppData\Local\Mozilla"
			if(Test-Path $LocalProfile)
			{
				Remove-Item "$LocalProfile\*" -recurse -force
			}
			
			if(Test-Path $FirefoxProfile)
			{
				Remove-Item "$FirefoxProfile\*" -recurse -force
			}
			
			New-Item -ItemType Directory -Force -Path "$FirefoxProfile\Firefox"

			& "$ProgramsPath\7-Zip\7z.exe" x -y .\firefox-profile.7z
			move ".\Firefox\*" "$FirefoxProfile\Firefox" -force
			icacls "$FirefoxProfile" /reset /t /c /q  
			Remove-Item .\firefox-profile.7z
		} 
	}
}
Diese Antwort im Kontext lesen 👍 0

Alle Antworten (10)

more options

Maybe it is better if you try to explain your objectives, what do you need to achieve. ( Not sure I will be able to help! )

You could try cloning parts of a profile and keeping those updated with your own code. You could even setup your own sync server.

However your plan seems to be to try to use a single profile for multiple different Firefox users I suspect that will not work. I would not even attempt to use a single profile for all Windows users or all Ubuntu users and certainly not share one between differing OS s ( I know that has been tried, with some limited success.)

If you wish to point Firefox at any particular profile so that it uses it you could edit the file profiles.ini or you could follow these instructions:

In a standard Windows vs Ubuntu it is worth noting Windows will use a Mozilla build and Ubuntu a Canonical build they will often not even be exactly the same versions, as the dates of releases do not match. Yes you could install Mozilla Firefox in Ubuntu but the addons will not necessarily match & the plugins will differ.

more options

By the way if you are trying to deploy Firefox for multiple users and multiple machines look at

more options

John99 said

By the way if you are trying to deploy Firefox for multiple users and multiple machines look at

Thank you for this information I learnt something new. I will take a look. However, the CCK2 support it is very expensive 499$ :(. I cannot afford such cost.

Geändert am von erotavlas

more options

John99 said

Maybe it is better if you try to explain your objectives, what do you need to achieve. ( Not sure I will be able to help! ) You could try cloning parts of a profile and keeping those updated with your own code. You could even setup your own sync server. However your plan seems to be to try to use a single profile for multiple different Firefox users I suspect that will not work. I would not even attempt to use a single profile for all Windows users or all Ubuntu users and certainly not share one between differing OS s ( I know that has been tried, with some limited success.) If you wish to point Firefox at any particular profile so that it uses it you could edit the file profiles.ini or you could follow these instructions: In a standard Windows vs Ubuntu it is worth noting Windows will use a Mozilla build and Ubuntu a Canonical build they will often not even be exactly the same versions, as the dates of releases do not match. Yes you could install Mozilla Firefox in Ubuntu but the addons will not necessarily match & the plugins will differ.

My final objective is to install the same firefox profile with all add on and customization for all the users of each system (Linux/Ubuntu, Windows). I know that I need two different "source" profiles one for Linux/Ubuntu and the other for Windows. At the moment, my previous script works well only for the administrator user of the system that executes the script and installs with success the "source" profile for himself. My scripts are doing the steps describe here http://kb.mozillazine.org/Moving_your_profile_folder under Create a new profile and copy the old one over it from command line. It seems that the commands


firefoxProfile="/home/$systemUser/.mozilla/firefox"
firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile"

are creating the profile for the administrator user profiles.ini instead for the user whose data directory is located at "/home/$systemUser/.mozilla/firefox".

My question is: can I create a new firefox profile from command line by using the administrator user for another user in the system with data folder located in a different path (Linux/Ubuntu, Windows)?

Note: I do not want create multiple profiles for the same system user, but a new profile (with the same profile data) for different users in the system.

Edit: I tried again many times. I think that I cannot create a profile from administrator user for a different user in the system. Do you confirm this? Edit2: I also think that it could be a bug of firefox since firefox -CreateProfile "profile /home/user/.mozilla/firefox/m4v6pi7q.profile" or sudo firefox -CreateProfile "profile /home/user/.mozilla/firefox/m4v6pi7q.profile" return Success: created profile 'profile /home/user/.mozilla/firefox/m4v6pi7q.profile' at '/home/admin-user/.mozilla/firefox/m4v6pi7q.profile/prefs.js' Why is the path in the command different from the actual path used?

Geändert am von erotavlas

more options

erotavlas said

Thank you for this information I learnt something new. However, the CCK2 it is very expensive 499$ :(. I cannot afford such cost.

No it is free. The software has been around for years from Kaply, and previously hosted on the standard mozilla addons. It is only the professional support service that is charged for.

more options

John99 said

erotavlas said
Thank you for this information I learnt something new. However, the CCK2 it is very expensive 499$ :(. I cannot afford such cost.

No it is free. The software has been around for years from Kaply, and previously hosted on the standard mozilla addons. It is only the professional support service that is charged for.

Yes of course. Thank you for this.

more options

You do not even need to use the command line. Just copy and paste the new profile over the existing profile. The key is to leave the profile path and name as it was.

So if the old source profile is displaying in the profile manager as

default

and the folder is

12345678.default

But the second user has a profile displaying as

default

but the folder is

87654321.default

Then the replacement folder need be renamed after it is copied so that it is 87654321.default. Or the relevant profles.ini needs to be edited to point at 12345678.default You will have multiple profile.ini files

I often mention to anyone new to using the profile manager do not use it rename or delete profiles leave them as they are once created. The profile manger changes profile names, but does not change the profile path. That gives a confusing mismatch between the profile name displayed and the name of the folder used.

If you are use the Firefox command lines all you do is invoke the profile manger functions.

If you want to use the same data you are best just overwriting individual files. Very similar to the procedure explained in

No doubt you could use a bat file or bash script to do that automatically. (I never learnt how to use powershell that's probably the method now on Windows )

more options

Ausgewählte Lösung

Hi, I solved with a brilliant idea. Since I need to install in many PC the same firefox profile and these PC should have only this profile, I can avoid to use the command firefox -CreateProfile "profile $firefoxProfile/m4v6pi7q.profile that is the source of the problem. I can directly move the firefox folder with profiles.ini inside plus the m4v6pi7q.profile and crash reports folders into the home folder of each user in the system. This works perfectly. I report the Linux/Ubuntu script


usersList=$(getent passwd | grep -vE '(nologin|false)$' | \
awk -F: -v min=`awk '/^UID_MIN/ {print $2}' /etc/login.defs` \
-v max=`awk '/^UID_MAX/ {print $2}' /etc/login.defs` \
'{if(($3 >= min)&&($3 <= max)) print $1}' | \
sort -u)

for systemUser in $usersList; do
	firefoxProfile="/home/$systemUser/.mozilla"
	if [ ! -d "$firefoxProfile/firefox/m4v6pi7q.profile" ]; then
		echo "Installing Firefox profile for user: $systemUser"
		sudo rm -rf $firefoxProfile
		sudo mkdir -p $firefoxProfile
		7z x -y ./firefox-profile.7z > /dev/null | egrep "p7zip|Ok"
		sudo mv ./firefox "$firefoxProfile/firefox"
		sudo chown -R $systemUser:$systemUser $firefoxProfile
		rm -rf firefox-profile.7z
	fi
done

and Windows script

$UsersList=(Get-WmiObject -Class Win32_UserAccount -filter "LocalAccount = True" | Select name)
ForEach($SystemUser in $UsersList)  
{ 
	$SystemUser=$systemUser.name
	# CompareTo returns 0 if strings are equal
	if($SystemUser.CompareTo("Administrator") -and $SystemUser.CompareTo("Guest") -and $SystemUser.CompareTo("HomeGroupUser$" ) -and $SystemUser.CompareTo("DefaultAccount"))
	{
		$UserPath="C:\Users\$systemUser"
		$FirefoxProfile="$UserPath\AppData\Roaming\Mozilla"
		if(-Not (Test-Path "$FirefoxProfile\Firefox\Profiles\u9w6vbcj.profile"))
		{
			Write-Host "Installing Firefox profile for user: $SystemUser"
			$LocalProfile="$UserPath\AppData\Local\Mozilla"
			if(Test-Path $LocalProfile)
			{
				Remove-Item "$LocalProfile\*" -recurse -force
			}
			
			if(Test-Path $FirefoxProfile)
			{
				Remove-Item "$FirefoxProfile\*" -recurse -force
			}
			
			New-Item -ItemType Directory -Force -Path "$FirefoxProfile\Firefox"

			& "$ProgramsPath\7-Zip\7z.exe" x -y .\firefox-profile.7z
			move ".\Firefox\*" "$FirefoxProfile\Firefox" -force
			icacls "$FirefoxProfile" /reset /t /c /q  
			Remove-Item .\firefox-profile.7z
		} 
	}
}

Geändert am von erotavlas

more options

Note that Firefox uses a second location in "~/.cache/mozilla/firefox/" that is used for the disk cache. If you only move the main Firefox profile folder then you still would have the other part left in the location in root where the profile got created.

more options

cor-el said

Note that Firefox uses a second location in "~/.cache/mozilla/firefox/" that is used for the disk cache. If you only move the main Firefox profile folder then you still would have the other part left in the location in root where the profile got created.

Yes, but this folder is only for cache. The main folder is ~/.mozilla/firefox/. The profile works even without the cache whereas the opposite is not true.