Firefox is already running
If you try to open Firefox and get the message “Firefox is already running”, close all Firefox windows and try this script. It removes the leftover lock files:
#!/bin/bash
find ~/.mozilla -name "*lock" -print0 |
while IFS= read -r -d '' file; do
echo "removing $file..."
rm "$file"
done
Make sure Firefox is really closed first (pgrep -a firefox shows nothing).
The script only looks in ~/.mozilla. Depending on how Firefox is installed, the profile can also be in:
| Firefox from | Profile folder |
|---|---|
| Snap (Ubuntu default) | ~/snap/firefox/common/.mozilla |
| Flatpak | ~/.var/app/org.mozilla.firefox/.mozilla |
| Newer versions (XDG) | ~/.config/mozilla/firefox |
Use that folder instead of ~/.mozilla in the find command.