≡ Menu

HowTo: Run Firefox From The Command Line

How do I run Firefox browser from the Linux command line (shell prompt)? How to run Firefox from command line on Linux based server?

You can use command line as follows with special arguments to start Mozilla firefox.

Firefox Start Browser

To open the browser, enter:
$ firefox
$ /usr/bin/firefox

Firefox Open URL

To open URL in a new tab, enter:
$ /usr/bin/firefox -new-window http://www.cyberciti.biz/
To open URL in a new window, enter:
$ /usr/bin/firefox www.cyberciti.biz

Firefox Search option

You can search words (term) with your default search engine, enter:
$ /usr/bin/firefox -search "term"
$ /usr/bin/firefox -search "linux add user to group"

Open Firefox Options / Preferences

To open Firefox options/preferences window, enter:
$ /usr/bin/firefox -preferences

Set Firefox As Default Browser

To set the Firefox app as the default browser, enter:
$ /usr/bin/firefox -setDefaultBrowser

How Do I Run Firefox Remotely On Server?

SSH is frequently used to tunnel insecure traffic over the Internet in a secure way. You can login to remote server using the ssh client:
$ ssh -X user@server42.nixcraft.com
To run firefox, enter:
$ /usr/bin/firefox &
$ /usr/bin/firefox www.cyberciti.biz

Share this tutorial on:
{ 15 comments… add one }
  • anonymousApril 2, 2011, 11:34 am


    the shell comand “firefox” does only work if you start in from a e.g. gnome terminal, and gnome is running on this display.

    what is the command if you want start friefox e.g on tty1 , where no desktop is running?

    linux says ” error : no display specified”
    How to specify the display ?

    or does it only work when starting from tty7 (where the desktop is running) in this case i’m wondering about the advantage starting from a shell. because you could also click on the firefox button in front panel.

    thx for advice

    • AnonimousTwoMay 5, 2012, 6:32 pm

      You need 2 command lines. (you do not need to be logged as root)

      But first you need :
      To get the X server installed = xserver-xorg
      To get a graphical interface installed : Gnome or KDE or LXDE or XFCE or whatever you want…
      To be located and log on in a TTY console

      The first command line is to set the variable “DISPLAY” to “:0” by the following :
      username@localhost:~$ export DISPLAY=:0

      To verify your work has been done efficiently you may enter, to see the value of your variable :

      username@localhost:~$ echo $DISPLAY

      You should get :

      The second one by entering the program name you need to run, iceweasel for exemple :
      username@localhost:~$ /usr/lib/iceweasel/firefox.bin http://www.debian.org &

      NOTA : The sign “&” at the end gives you back the command line available.

      …and it will start firefox on the web page http://www.debian.org in you graphical interface…

      Have fun and thank you !!! So much !!!

  • AnonimousTwoMay 5, 2012, 6:46 pm

    My previous topic gives you how to start a graphical software in tty7 from a command line in tty console like tty1 to tty6.
    It’s helpfull to run a software remotly.
    You need to get you desktop environment started.
    By I should know, it’s not possible to start a graphical software from the console without your desktop environment started.
    If you want to navigate on the Internet by a command line software in text mode from the console, you should use “Lynx”

  • Kent ByeSeptember 4, 2012, 12:27 am

    open -a /Applications/Firefox.app http://example.com is what I use from the Mac terminal

  • GokulJanuary 16, 2013, 5:50 pm

    HI Vivek,

    I removed firefor old version using yum command. And downloaded firefox 18 .tar.bz2.

    Unzipped the tar file in /home/user/firefox.

    [root@localhost firefox]# /usr/bin/firefox
    bash: /usr/bin/firefox: No such file or directory

    Is that any settings i need to do?

    • vijayApril 4, 2013, 11:50 am

      you need to install the package and then see the following is present

  • AnonymousMay 13, 2013, 10:31 pm

    Hey I was wondering if I could close a tab in terminal? i wanted to run a bash script that opened a particular window and close it. for example i have


    firefox http://www.google.com –new-window

    now i’m stuck with an open window i want to close. Is there a way to do it in terminal?

  • cDecember 20, 2013, 6:47 am

    Open new tab:
    $ /usr/bin/firefox -new-window http://www.cyberciti.biz/
    change new-window for new-tab

  • gopuJanuary 20, 2014, 6:32 pm

    How to keep alive firefox from ssh command. actually i want to keep alive firefox & open tabs after vnc viewer off. i m using skype form vps vnc viewer & skype via http://www.plus.im. so i want to know how to keep alive that firefox pages.


  • gopuJanuary 22, 2014, 11:53 am

    solve this problem with skype/vnc/ubuntu.

  • TylerAugust 15, 2014, 6:48 pm

    Dear Editor,

    under Firefox Open URL, -new-window is used to open a new window and will not open a tab. Simple typo anyone could make. :)

  • stanislavJanuary 20, 2015, 11:15 pm

    if ps aux | grep “midori” | grep -v grep ; then env DISPLAY=:0 midori ; fi

    do nothing :(

  • BhumiFebruary 5, 2015, 12:09 pm

    How can i start firefox using exec command in php? i am using ubuntu.

  • derZimmermannAugust 29, 2015, 9:42 am

    if you want that the browser stay open when closing the executing terminal session you have to use the nohup command.
    In my case:

    export DISPLAY=:0";"nohup /usr/lib/iceweasel/iceweasel URLOFWEBSITE &

    worked fine.

  • surendarMarch 31, 2016, 2:17 pm

    how to open firefox in private window ..in linux pls help

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , ,