Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to type firefox in terminal and run Mozilla browser.

So I try to create sym-link: ln -s /opt/firefox firefox

but after typing firefox in terminal I get an error: bash: firefox: command not found

Where is problem?

share|improve this question

migrated from serverfault.com Sep 12 '12 at 11:32

This question came from our site for professional system and network administrators.

3 Answers 3

up vote 3 down vote accepted

You created a link to /opt/firefox (is this really the firefox binary, can you start FF when calling /opt/firefox?) in the directory that was your current working directory when you issued the command, likely your home directory.

However, the directory where your link was created is not in your $PATH, so you still can't run it directly.

The solution is to either create the link into a directory with is in your path. E.g.:

ln -s /opt/firefox /usr/local/bin/firefox

or add /opt to your path, but I would recommend the first option.

A remark: /opt/ is a strange place to put a binary in. How did you install Firefox anyway and why didn't you use your distributions package management system?

share|improve this answer
    
I downloaded tar.bz2 file of Firefox and unarchived it to /opt/. Hmm, where is place to put binary files in linux? P.S. Sym-lin (i.e. ln -s command) add information to $PATH environment variable? –  MyTitle Sep 12 '12 at 10:33
1  
As I said, you ususally install software with the tools your distribution offers. Try apt-get install firefox (Debian, Ubuntu) or yum install firefox (Redhat, Centos, Fedora, Suse). If you downloaded and untarred the file in /opt/, it will likely have created a subdirectoy /opt/firefox and the binary to start` is /opt/firefox/firefox. The link to create would be ln -s /opt/firefox/firefox /usr/local/bin/firefox. –  SvW Sep 12 '12 at 10:40
    
You can search serverfault or google to learn how to add stuff to your $PATH. –  SvW Sep 12 '12 at 10:41
    
yes, I tried /opt/firefox/firefox - it too don't help, but ln -s /opt/firefox/firefox /usr/local/bin/firefox helped! thanks. export PATH=$PATH:/new/path (as answered binfalse) exist only within terminal session, but after executing your command reference to firefox persisted in system..But can you explain why you mapped firefox.sh to local/bin/firefox? Why local/bin/firefox? –  MyTitle Sep 12 '12 at 10:56
    
Simple. /usr/local/bin is usually in the default $PATH as defined by the OS and I like to put nonstandard binaries in there, as this was the tradtional location for local installs. –  SvW Sep 12 '12 at 11:01

First of all please make sure, that /opt/firefox is the executable and not a director. Try to execute /opt/firefox, if that works you can add the directory with the executable to your $PATH variable.

Supp

If you try to execute a command cmd, your system scans all path elements in this variable for an executable with the name cmd. If you want to extend the directories to scan just update the variable like:

export PATH=$PATH:/new/path

So the next time you try to run cmd your systems also looks for the executable in /new/path. That means, if your firefox executable is located in /opt just add the following to your .bashrc:

export PATH=$PATH:/opt
share|improve this answer
    
yes. you right. helped. But I use CentOs, and I know if I execute export command so "exported" variable will exist only within terminal session, after closing terminal all variables added using export will be removed - this rules also may be applied in our case (i.e. extending $PATH variable)? Or this change will be saved (even after reboot) because we only extend (not create) $PATH? –  MyTitle Sep 12 '12 at 10:47
    
@MyTitle: If you add the line to your ~/.bashrc file, it will be permanent (if you use the bash, of course). –  SvW Sep 12 '12 at 10:52

The default firefox executable when Firefox is installed usually resides in /usr/lib/firefox- which is a directory:

Please try to verify this on your system with the command:

ls /usr/lib/firefox* 

which on my system yields the result:

drwxr-xr-x 13 root root 1020 2012-09-12 06:29 /usr/lib/firefox-3.6.28
drwxr-xr-x  6 root root  916 2011-04-25 18:56 /usr/lib/firefox-4.0
drwxr-xr-x  7 root root   80 2011-04-25 18:56 /usr/lib/firefox-addons

The Firefox icon at the top of a Linux main bar (top of monitor screen) is connected to the Firefox executable via a symbolic link in /usr/bin such as:

ls -lt firefox*

lrwxrwxrwx 1 root root 14 2012-09-12 06:29 firefox -> firefox-3.6.28
lrwxrwxrwx 1 root root 29 2012-09-12 06:29 firefox-3.6.28 -> ../lib/firefox-3.6.28/firefox

With this structure, you can have multiple versions of Firefox symbolically linked, and to try a different version you would simply remove the firefox link in /usr/bin, and then create a new firefox to a different version in /usr/lib, such as (where the # prompt below is the root account prompt:

# rm firefox
# ln -s ../lib/firefox-4.0/firefox.sh firefox

As mentioned in previous posts on this topic, you need to make sure that the linked-to object actually exists when you create a symbolic link to it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.