Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I found there is some differences between the utility command I used on the mac OSX and linux. I want to make my experience united.

How could I replace all my mac utilities with GNU utilities?

share|improve this question
See also apple.stackexchange.com/questions/71119/…. – lhf Nov 9 '12 at 23:44

3 Answers

up vote 7 down vote accepted

This adds symlinks of gnu utilities with a g prefix to /usr/local/bin/:

brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt

See brew search gnu for other packages. If you want to use the default names, install the formulas with --default-names. Or for coreutils, add /usr/local/opt/coreutils/libexec/gnubin before other folders on the path.

$ brew info coreutils
coreutils: stable 8.21
http://www.gnu.org/software/coreutils
Depends on: xz
/usr/local/Cellar/coreutils/8.20 (208 files, 9.4M)
/usr/local/Cellar/coreutils/8.21 (210 files, 9.6M) *
https://github.com/mxcl/homebrew/commits/master/Library/Formula/coreutils.rb
==> Caveats
All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

    MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
share|improve this answer

I'm not sure that I would recommend replacing them; however, you can install them to a different path and utilize them that way. Overall, if you are coming from Linux and would like access to more "generic" *nix utilities, and a system similar to apt, then I would recommend looking into Macports: http://www.macports.org

It allows, for example, using the latest "generic" GCC, as opposed to/in addition to Apple's included GCC, just as an example.

share|improve this answer
2  
For instance, tar and zip from Mac OS X know about metadata that the GNU versions do not. – lhf Oct 22 '12 at 17:49
There are Apple supplied apps, which are just GUIs for some command line tools and if you replace them the apps may start behaving strangely, so go with adding, not replacing. – Mark Thalman Oct 23 '12 at 11:56
Right; something like Macports adds them, it doesn't replace them. – Jonathan Oct 23 '12 at 12:10

Besides brew install coreutils, you may also need to install some other packages, such as gnu-sed, grep:

brew install findutils --default-names
brew install gnu-indent --default-names
brew install gnu-sed --default-names
brew install gnutls --default-names
brew install grep --default-names
brew install gnu-tar --default-names
brew install gawk

The --default-names option is optional, turn on this if you really need to use these GNU commands as default ones, or they will be compiled with a g prefix.

Reference: http://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/

share|improve this answer
Could you please summarise the info here and not just provide a link - answers should be standalone with links only for extra information – Mark Apr 15 at 8:36
1  
Welcome to the site. Answers on Ask Different need to be more than just a link. It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone. – patrix Apr 15 at 8:43
Thanks for your comments! I'll edit it. – xuhdev Apr 15 at 15:42

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.