How to set environment for gfortran as a user in Linux?

Viewed 1575

I installed gfortran as a user in a server. But I can't able to set the environment. Would someone help me with it?

I am able to use gfortran with the following command:

/home/kay/gcc-4.8.5/bin/gfortran

I tried to set my environment with following, but not working.

$ vi ~/.bashrc
$ export gfortran=/home/kay/gcc-4.8.5/bin/gfortran
$ source ~/.bashrc

When I type:

$ gfortran 
command not found

But when I type:

$/home/kay/gcc-4.8.5/bin/gfortran
fatal error: no input file
1 Answers

The export command is used to define and environment variable. What you need is called an "alias".

Add this line to your ~/.bashrc file:

alias gfortran="/home/kay/gcc-4.8.5/bin/gfortran"

Then run source ~/.bashrc and the gfortran command will execute the binary located at /home/kay/gcc-4.8.5/bin/gfortran.

Related