pgrep command to identify the process ID or by inspecting the active profile directory within your home folder. These methods allow you to verify if the browser is running, manage multiple instances, or troubleshoot unresponsive windows without relying on unreliable content process signals.
Identifying the Process via Terminal
The most reliable way to confirm that Firefox is currently running and to obtain its specific process identifier is through the terminal. This approach works across almost all Linux distributions regardless of the desktop environment. You should use thepgrep utility with the -a flag, which displays both the process ID and the full command line arguments.
Run the following command in your terminal:
pgrep -a firefox
This output will show you the main Firefox process. If you see a single entry, it is likely the parent process managing the tabs. If you see multiple entries, one is usually the parent (often labeled with --parent-pid) and others are child processes handling individual tabs or web content. For simple existence checks, you can also use:
pgrep firefox
If this returns a number, Firefox is running. If it returns nothing, the application is not active. Note that some systems may label the binary as firefox-esr for Extended Support Release versions, so you might need to search for that string instead.
Locating the Active Profile Directory
Firefox stores user data, including open sessions and history, in a specific profile directory. By default, this location varies slightly depending on your distribution but generally resides under~/.mozilla/firefox/. To find the exact path of the currently active session, you can list the contents of this directory.
Execute this command to see your profiles:
ls -la ~/.mozilla/firefox/
You will typically see a directory named something like xxxxxxxx.default-release. The "default" part indicates the primary profile. If you have multiple profiles, they will appear here as well. To interact with the session directly, such as viewing open files or debugging, you can navigate into this folder. However, be cautious when modifying files here while the browser is open, as it can lead to data corruption.
For more advanced users who need to know exactly which profile a running instance is using, you can check the command line output from pgrep -a firefox. Look for the -profile argument followed by the absolute path to the profile directory. This confirms which specific session is active if you have launched multiple instances with different profiles.
Managing Multiple Instances
Linux allows you to run multiple independent Firefox sessions simultaneously. This is useful if you want to separate work browsing from personal browsing without sharing cookies or history. Each instance uses its own profile directory. To launch a new session with a specific profile, you can use the-P flag.
firefox -P MyWorkProfile
This opens a profile manager dialog where you can select an existing profile or create a new one. Once selected, a completely isolated Firefox window opens. To manage these sessions, you can use the pgrep method described earlier. Each instance will have a distinct process ID. If you need to close a specific instance, you can kill its process ID using kill [PID], though it is safer to close the window normally to ensure proper session saving.
Troubleshooting Unresponsive Sessions
Sometimes Firefox appears frozen or unresponsive. Before resorting to forceful termination, try checking if the process is still alive. Usepgrep -a firefox again. If the process exists but the UI is stuck, you might try sending a signal to refresh it. However, killing the main process will close all tabs in that instance.
If you cannot close the window normally, you can force quit it using the process ID found earlier:
kill -9 [PID]
Use this sparingly, as it does not save the session state properly. After killing the process, you can restart Firefox. On the next launch, Firefox often detects that it was not closed cleanly and offers to restore your previous session. This feature relies on the session store files located in the profile directory mentioned in the previous section.
Related Resources
If you are experiencing issues with launching Firefox or managing its startup behavior, consider reading our guide on how to Speed Up Slow Firefox Startup on Linux Systems. Additionally, if you need to manage multiple tabs and preserve context between sessions, learn how to Open a Link in a New Firefox Tab, Copying the Current Tab History.Frequently Asked Questions
How do I see all open tabs in a running Firefox session?
You cannot view the list of open tabs directly from the terminal without third-party tools. The standard approach is to bring the Firefox window to the foreground and check the tab bar. For scripting purposes, you must rely on the session store JSON file in the profile directory.
Can I connect to a running Firefox instance remotely from another machine?
No, Firefox does not support remote control connections out of the box on standard Linux installations. You would need to set up a VNC server or use remote desktop software to access the graphical interface of the machine running Firefox.
What happens to my open tabs if I kill the Firefox process?
Killing the process prevents the normal shutdown sequence, which means tabs are not saved gracefully. However, Firefox's crash recovery system usually restores them upon the next launch. It is always better to close the window normally to ensure no data is lost.
How do I find the profile path if pgrep doesn't show it?
If the command line does not show the profile path, you can assume the default profile is being used. Check the ~/.mozilla/firefox/ directory for folders ending in .default-release or similar. This is the most common configuration for single-user setups.
Is it safe to delete files in the Firefox profile folder while it is running?
No, it is highly unsafe. Deleting or modifying files in the active profile directory while Firefox is running can corrupt the session store, bookmarks, or preferences. Always close Firefox before making changes to its profile data.