Copying from /usr/local/bin to /usr/bin?

  • Thread starter CAF123
  • Start date
In summary, it is possible to copy or move an executable from /usr/local/bin to /usr/bin, but this requires root permissions. If you are using a Linux shell, you can type sudo cp /usr/local/bin/gfortran/ /usr/local/bin or sudo ln -s /usr/local/bin/gfortran/ /usr/bin/ to make the symbolic link.
  • #1
CAF123
Gold Member
2,948
88
I'd like to move (or copy) an executable (namely the gfortran one) from /usr/local/bin to /usr/bin. Is it possible?
Copy and pasting via the Go to folder doesn't work probably because it requires permissions and I have tried sudo cp /usr/local/bin/gfortran/ /usr/local/bin in the terminal but it said the operation was not permitted after putting in my MAC password. Also I consider myself a computer noob so probably being silly somewhere. Is the gfortran executable a Fortran 77 compiler?

Thanks!
 
Technology news on Phys.org
  • #2
CAF123 said:
I'd like to move (or copy) an executable (namely the gfortran one) from /usr/local/bin to /usr/bin. Is it possible?
Yes, but as you found out, you need root permissions for that. Perhaps better would be to either put /usr/local/bin in your $PATH, or make a symbolic link from /usr/local/bin to /usr/bin. Assuming you are in a shell inside the /usr/bin directory and you have root permissions, you could type
Code:
ln -s /usr/local/bin/gfortran .
to make the symbolic link.
CAF123 said:
I have tried sudo cp /usr/local/bin/gfortran/ /usr/local/bin in the terminal but it said the operation was not permitted after putting in my MAC password.
I don't know how one becomes root on a MAC, but this should be Googleable. In my Linux Bash shell, I would type
Code:
su -
to become root.
CAF123 said:
Is the gfortran executable a Fortran 77 compiler?
Yes, it compiles Fortran 77 just fine. If you are writing new software, I would recommend using Fortran 90 or newer. (It is safer, more readable, has better matrix support... Simply more up-to-date.)
 
Last edited:
  • Like
Likes FactChecker
  • #3
Software suites like gcc (of which gfortran is part) often depend on particular directory structures, so simply moving a single file will probably not do the trick. Either use @Krylov's advice of running it from /usr/local/bin or reinstall gcc to use /usr/bin.

CAF123 said:
sudo cp /usr/local/bin/gfortran/ /usr/local/bin
That should've worked, but without the / after gfortran.

Krylov said:
I don't know how one becomes root on a MAC, but this should be Googleable. In my Linux Bash shell, I would type
Code:
su -
to become root.
There is no superuser account on Macs (for security reasons). One has to use sudo to perform su operations in a terminal.

For more information on compiling fortran on the Mac, I recommend http://hpc.sourceforge.net
 
  • Like
Likes I like Serena
  • #4
CAF123 said:
I'd like to move (or copy) an executable (namely the gfortran one) from /usr/local/bin to /usr/bin. Is it possible?
Copy and pasting via the Go to folder doesn't work probably because it requires permissions and I have tried sudo cp /usr/local/bin/gfortran/ /usr/local/bin in the terminal but it said the operation was not permitted after putting in my MAC password. Also I consider myself a computer noob so probably being silly somewhere. Is the gfortran executable a Fortran 77 compiler?
The correct command would be:
Code:
sudo cp -r /usr/local/bin/gfortran/ /usr/bin
with the target directory /usr/bin instead of /usr/local/bin, and with -r indicating copying recursively.
I would suggest moving though with:
Code:
sudo mv /usr/local/bin/gfortran/ /usr/bin
From wiki:
wiki said:
GNU Fortran or GFortran is the name of the GNU Fortran compiler, which is part of the GNU Compiler Collection(GCC). GFortran has replaced the g77 compiler, on which development stopped before GCC version 4.0. It includes full support for the Fortran 95 language and is compatible with most language extensions supported by g77, allowing it to serve as a drop-in replacement in many cases. Large parts of Fortran 2003 and Fortran 2008 have also been implemented.
 
  • #5
I like Serena said:
The correct command would be:
Code:
sudo cp -r /usr/local/bin/gfortran/ /usr/bin
with the target directory /usr/bin instead of /usr/local/bin, and with -r indicating copying recursively.
I would suggest moving though with:
Code:
sudo mv /usr/local/bin/gfortran/ /usr/bin
gfortran is an executable file, not a directory.
 
  • #6
Consider @DrClaude advice and do not move executables around especially in the /usr tree. /usr should be maintained only by existing code and installer scripts, do not mess with it, even on a mac.
Why? you can easily cause the system to fail to boot with one small change, for example. File and runtime library dependencies are best left to the installer, not the owner.
 
  • #7
DrClaude said:
gfortran is an executable file, not a directory.
Ah, in that case I definitely recommend against copying or moving, since there will be other parts of the compiler that won't be taken along, with the result that it won't work anymore.
(And a possible reason for the failure is the trailing slash (/) that identifies gfortran as a directory.)

Then a symbolic link would be more appropriate as @Krylov suggested:
Code:
sudo ln -s /usr/local/bin/gfortran /usr/bin/

Or alternatively, uninstalling and reinstalling.
Or adding /usr/local/bin to the PATH environment variable.
Or defining gfortran as an alias for /usr/local/bin/gfortran.
 
Last edited:
  • #8
Many thanks for all these replies. Maybe it's worth explaining what I am trying to do - basically I want to use something called LoopTools and that requires a Fortran 77 compiler, gcc, g++ and make. I see that in the past I have all such things already on my machine in the /usr/bin except the gfortran which is in /usr/local/bin. When I try to run the configure executable in the unpacked tar file for LoopTools (simply ./configure in terminal within LoopTools folder) I get terminal output saying Fortran-77 compiler not in PATH. So I'm thinking that the problem is that I need to move the fortran executable to /usr/bin because everything else needed (i.e make, gcc,g++) was found ok and they're all in /usr/bin. Am I thinking correctly? If not maybe there is a simpler solution.

Thanks again!
 
  • #9
CAF123 said:
Many thanks for all these replies. Maybe it's worth explaining what I am trying to do - basically I want to use something called LoopTools and that requires a Fortran 77 compiler, gcc, g++ and make. I see that in the past I have all such things already on my machine in the /usr/bin except the gfortran which is in /usr/local/bin. When I try to run the configure executable in the unpacked tar file for LoopTools (simply ./configure in terminal within LoopTools folder) I get terminal output saying Fortran-77 compiler not in PATH. So I'm thinking that the problem is that I need to move the fortran executable to /usr/bin because everything else needed (i.e make, gcc,g++) was found ok and they're all in /usr/bin. Am I thinking correctly? If not maybe there is a simpler solution.

Thanks again!
Yes, I think we can offer a simpler solution.
How about:
Code:
export PATH=$PATH:/usr/local/bin
./configure
 
  • #10
I like Serena said:
Yes, I think we can offer a simpler solution.
How about:
Code:
export PATH=$PATH:/usr/local/bin
./configure
Oh I just tried it in the terminal while I was in the LoopTools directory and it gave me the same error message :/
 
  • #11
CAF123 said:
Oh I just tried it in the terminal while I was in the LoopTools directory and it gave me the same error message :/
Which error message exactly?
 
  • #12
I like Serena said:
Which error message exactly?
I went to the LoopTools folder and typed in the terminal
Code:
MyName-MacBook-Pro:LoopTools12 myname$ export PATH=$PATH:/usr/local/bin

MyName-MacBook-Pro:LoopTools12 myname$ ./configure

and I get terminal output

Code:
looking for make... /usr/bin/Make

looking for Fortran... no Fortran-77 compiler in your path.
 
  • #13
CAF123 said:
I went to the LoopTools folder and typed in the terminal
Code:
MyName-MacBook-Pro:LoopTools12 myname$ export PATH=$PATH:/usr/local/bin

MyName-MacBook-Pro:LoopTools12 myname$ ./configure

and I get terminal output

Code:
looking for make... /usr/bin/Make

looking for Fortran... no Fortran-77 compiler in your path.
It looks as if your 'configure' script does not recognize gfortran as a a Fortran-77 compiler.
To confirm, we need a bit more information what ./configure is looking for exactly, meaning we need more verbose output.
Something like:
Code:
./configure --help
should show how to get more verbose output.
 
  • #14
ah it gave me the same terminal output as above, when I tried with just ./configure. Would you perhaps recommend I reinstall another fortran-77 compiler then?
 
  • #15
First give this command at the command line: echo $PATH

to see which directories are in your path. If it doesn't contain /usr/local/bin, then:

Give the command: echo $SHELL

This will tell you what your default shell is. On my old MacOS (10.9.5) system, it's /bin/bash.

In my home directory, I created (a long time ago) a file named .bash_profile (note the '.' at the beginning) which contains:

PATH=/Users/jtbell/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH
export PATH

If you're using bash also, create this file (or edit it if it exists already), and include /usr/local/bin in your path. You don't need the other directories that I have:

PATH=/usr/local/bin:$PATH
export PATH

If you're not using bash, you need to make a similar change in a different file, but the syntax may be different.
 
  • #16
CAF123 said:
ah it gave me the same terminal output as above, when I tried with just ./configure. Would you perhaps recommend I reinstall another fortran-77 compiler then?
That's probably indeed the easiest way forward.
It looks as if your ./configure script is a bit dated, so to make it work we may need an older fortran-77 compiler.
 
  • #17
@jtbell I tried echo $PATH and I see that both /usr/local/bin and /usr/bin are listed, amongst others. Probably I should proceed with reinstalling another compiler, as I like Serena thinks might also help.

@I like Serena Do you know where I can find a compiler that would work? I have done a google search but lots of hits, sorry wish I was more computer savvy :)
 
  • #18
CAF123 said:
@jtbell I tried echo $PATH and I see that both /usr/local/bin and /usr/bin are listed, amongst others. Probably I should proceed with reinstalling another compiler, as I like Serena thinks might also help.

@I like Serena Do you know where I can find a compiler that would work? I have done a google search but lots of hits, sorry wish I was more computer savvy :)
If, when you type gfortran in the terminal window, it executes correctly, then the problem is not your installation, it is LoopTools. Check the information in that package concerning installation.
 
  • #19
CAF123 said:
@jtbell I tried echo $PATH and I see that both /usr/local/bin and /usr/bin are listed, amongst others. Probably I should proceed with reinstalling another compiler, as I like Serena thinks might also help.

@I like Serena Do you know where I can find a compiler that would work? I have done a google search but lots of hits, sorry wish I was more computer savvy :)
Googling for it actually usually leads to gfortran... although I also see references to a f77 compiler.
Let's try/confirm something.
Try:
Code:
alias f77="/usr/local/bin/gfortran"
f77
./configure
It may already solve your immediate problem, and at least it will tell us:
- whether your gfortran actually works,
- whether the configure script looks for f77.

DrClaude said:
If, when you type gfortran in the terminal window, it executes correctly, then the problem is not your installation, it is LoopTools. Check the information in that package concerning installation.
Good point.
I suggest looking in the directory for other files like README or INSTALL that may explain what is needed.
 
  • #20
@I like Serena @DrClaude Thanks, I tried the suggestion of
Code:
 alias f77="/usr/local/bin/gfortran"
f77
./configure
and it said that
Code:
gfortran: fatal error: no input files

compilation terminated.
The error happened when I typed in and executed f77 subsequent to executing alias f77 ="/usr/local/bin/gfortran"

The following is the output from the INSTALL file I find in the LoopTools folder

To install LoopTools you need a Fortran-77 compiler, GNU make, gcc,
and g++. Once you've got these installed, the rest is straightforward:

Run ./configure to configure the GNUmakefile.

Run gmake to build the libraries and binaries.

(Optional) Add $HOME/ff/$HOSTTYPE to your path or copy the files in
$HOME/ff/$HOSTTYPE to a public location (e.g. /usr/local/lib for the
libraries and /usr/local/bin for bra).
so I'm guessing once the problem with fortran 77 has been dealt with probably the rest should be ok.

Edit: Maybe I should also point out that there is also a utils folder inside LoopTools and that contains the following items, ccf, F77, F77.in, f77c, f77290.c and patchup. All but the f77290.c files are executables. I wonder if the F77 is the thing I need?
 
Last edited:
  • #21
CAF123 said:
gfortran: fatal error: no input files
compilation terminated.
The error happened when I typed in and executed f77 subsequent to executing alias f77 ="/usr/local/bin/gfortran"
That's expected. It confirms that the alias works, and that gfortran can actually run.
Question remains, what does ./configure say?

CAF123 said:
The following is the output from the INSTALL file I find in the LoopTools folder
so I'm guessing once the problem with fortran 77 has been dealt with probably the rest should be ok.

Edit: Maybe I should also point out that there is also a utils folder inside LoopTools and that contains the following items, ccf, F77, F77.in, f77c, f77290.c and patchup. All but the f77290.c files are executables. I wonder if the F77 is the thing I need?
Yes, the presence of those files suggest that you need f77, or perhaps it has to be named F77.

So... what does ./configure say now?
 
  • #22
Oh I didn't bother trying ./configure after I got the error from executing f77. But it just gives me the same error as before (that Fortran-77 not in my path). I wish I could move the F77 executable in the utils folder to the /usr/bin but I don't know how to do this (if you agree this would be a sensible thing to try)
 
  • #23
CAF123 said:
Oh I didn't bother trying ./configure after I got the error from executing f77. But it just gives me the same error as before (that Fortran-77 not in my path). I wish I could move the F77 executable in the utils folder to the /usr/bin but I don't know how to do this (if you agree this would be a sensible thing to try)
Neh. Just try the same alias trick, but now with 'F77' instead of 'f77'.
 
  • #24
I like Serena said:
Neh. Just try the same alias trick, but now with 'F77' instead of 'f77'.
Ah, same error as before :/
Code:
gfortran: fatal error: no input files

compilation terminated.
and ./configure gives again
Code:
looking for make... /usr/bin/Make

looking for Fortran... no Fortran-77 compiler in your path.
 
  • #25
CAF123 said:
Ah, same error as before :/
Code:
gfortran: fatal error: no input files

compilation terminated.
and ./configure gives again
Code:
looking for make... /usr/bin/Make

looking for Fortran... no Fortran-77 compiler in your path.
I guess we need to know a bit more about what that actually means.
Either we need more verbose output from configure, or we have to take a closer look at what its source code is doing.
Can you upload a zip of the whole thing? Or if it's too big, just the top level directory including that utils directory?
Alternatively, you might search for it with:
Code:
grep -R 'Fortran-77' .
and see what comes out.
 
  • Like
Likes CAF123
  • #26
The configure script probably uses its own instance of the shell. You will need to modify the shell control file .bashrc to set PATH properly.

I have checked that you do not need to create the f77 alias. It will find gfortran by itself, provided /usr/local/bin is in the path.
 
  • Like
Likes CAF123
  • #29
  • Like
Likes CAF123
  • #30
Thanks! Yes it was an older version that I had downloaded and hadn't realized. It now works :) I want to use this with mathematica, which has the simplest user interface. On page 29 (sect 1.6) it tells me to write Install["LoopTools"] after writing some path. Do you know what hosttype means?
 

Attachments

  • LT212Guide.pdf
    393.1 KB · Views: 223
  • #31
CAF123 said:
Thanks! Yes it was an older version that I had downloaded and hadn't realized. It now works :) I want to use this with mathematica, which has the simplest user interface. On page 29 (sect 1.6) it tells me to write Install["LoopTools"] after writing some path. Do you know what hosttype means?
Which directories do you have in the 'LoopTools' directory now?
There should be a new one that identifies your Mac somehow, and that's what the '(hosttype)' is.
 
  • #32
Thanks! Yes there was a new one called x86_64-Darwin so I guess that is it. Then I typed in
set path=$path $HOME/LoopTools/x86_64-Darwin/bin as instructed. I tried to then run Install["LoopTools"] within mathematica but it didn't work. What does it mean by the tsch and .cshrc? (if I need to do something there)
 
  • #33
CAF123 said:
Thanks! Yes there was a new one called x86_64-Darwin so I guess that is it. Then I typed in
set path=$path $HOME/LoopTools/x86_64-Darwin/bin as instructed. I tried to then run Install["LoopTools"] within mathematica but it didn't work. What does it mean by the tsch and .cshrc? (if I need to do something there)
Is 'LoopTools' in your home directory?
Can you check with the following command?
Code:
ls -l $HOME/LoopTools/x86_64-Darwin/bin

The usual shell on a Mac is 'bash' instead of 'tcsh' if I'm not mistaken.
And the corresponding configuration file is $HOME/.bashrc instead of $HOME/.cshrc .
So I think we need to modify the .bashrc instead.

That means editing $HOME/.bashrc and adding the following line:
Code:
export PATH=$PATH:$HOME/LoopTools/x86_64-Darwin/bin
After that Mathematica has to pick up the changed path somehow.
That may require logging out and back in.
 
  • #34
I've got LoopTools-2.14 in Downloads folder and the bin folder within the hosttype is located in Macintosh HD/Users/myname/Downloads/LoopTools-2.14/x86_64-Darwin/bin so maybe the beginning of that replaces HOME but not sure.

Oh I didn't get what you meant by modifying the .bashrc command. I wish these user manuals would be more noob friendly hehe
Thanks for your patience!
 
  • #35
Sure. No problem.
These unix tools tend indeed to require a certain level of unix command line knowledge.
What do you get after the following command?
Code:
ls -lA $HOME
Please leave out anything that is personal.
 

Similar threads

Replies
16
Views
2K
Replies
4
Views
1K
  • Beyond the Standard Models
Replies
14
Views
5K
Back
Top