pages tagged gnu http://meng6net.localhost/tag/gnu/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Tue, 16 May 2017 23:59:39 +0000 Installing and configuring GNU command-line utilities http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_command-line_utilities/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_command-line_utilities/ command-line computing configuration documentation gnu homebrew installation note software Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <h2>History</h2> <ul> <li>Last content verification: 2017-5-1, macOS 10.12.4, Homebrew 1.2.0.</li> </ul> <h2>macOS</h2> <p>If you've installed any of the softwares before, but would like to re-install it, (possibly because you want to make sure it's installed with the options such as <code>--with-default-names</code>, use <code>brew reinstall ...</code> in place of <code>brew install</code>.</p> <h3>GNU core utilities</h3> <p>The GNU Core Utilities (<a href= "http://www.gnu.org/software/coreutils/">coreutils</a>) contains "the basic file, shell and text manipulation utilities of the GNU operating system."</p> <pre><code>brew install coreutils </code></pre> <h3>Other GNU utilities</h3> <p>Run the following if not already in the past:</p> <pre><code>brew tap homebrew/dupes </code></pre> <p>Install utilities:</p> <pre><code>brew install binutils brew install diffutils brew install ed --with-default-names # brew install findutils --with-default-names ## This will cause 'brew doctor' to issue warning: "Putting non-prefixed findutils in your path can cause python builds to fail." brew install findutils brew install gawk brew install gnu-indent --with-default-names brew install gnu-sed --with-default-names brew install gnu-tar --with-default-names brew install gnu-which --with-default-names brew install gnutls brew install grep --with-default-names brew install gzip brew install screen brew install watch brew install wdiff --with-gettext brew install wget brew install gnupg brew install gnupg2 </code></pre> <p>The following utilities already exist on macOS, but install the newest version from Homebrew:</p> <pre><code>brew install bash brew link --overwrite bash # brew install emacs brew install --cocoa --srgb emacs ## brew linkapps emacs brew install gdb # gdb requires further actions to make it work. See `brew info gdb`. brew install guile brew install gpatch brew install m4 brew install make brew install nano </code></pre> <p>macOS has the following non-GNU utilities, but you can install and use a newer version instead of the version shipped by macOS:</p> <pre><code>brew install file-formula brew install git brew install less brew install openssh brew install rsync brew install svn brew install unzip brew install vim --override-system-vi brew install macvim --with-override-system-vim --custom-system-icons brew link --overwrite macvim brew linkapps macvim brew install zsh </code></pre> <p>Install Perl:</p> <pre><code>brew tap homebrew/versions brew install perl518 # must run "brew tap homebrew/versions" first! </code></pre> <p>Install Python:</p> <pre><code>brew install python brew linkapps python pip install --upgrade pip setuptools </code></pre> <h3>Configuration in <code>.bashrc</code></h3> <p>If installed GNU utilities without using the default names:</p> <pre><code>brew install ed #--with-default-names brew install findutils #--with-default-names brew install gnu-indent #--with-default-names brew install gnu-sed #--with-default-names brew install gnu-tar #--with-default-names brew install gnu-which #--with-default-names brew install grep #--with-default-names </code></pre> <p>i.e., installing them without the <code>--with-default-names</code> option, Homebrew will install the formulae with the prefix "<code>g</code>". If you still need to use these commands with their normal names, you can add a "gnubin" directory to your <code>PATH</code> in file <code>~/.bashrc</code>:</p> <pre><code>PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" ... # possibly others </code></pre> <p>Additionally, to make the man pages of the GNU versions of the utilities accessible via their normal names, add the <code>gnuman</code> directory to the <code>MANPATH</code> variable in the file <code>~/.bashrc</code>:</p> <pre> <code>MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH" MANPATH="/usr/local/opt/gnu-sed/libexec/gnuman:$MANPATH" MANPATH="/usr/local/opt/gnu-tar/libexec/gnuman:$MANPATH" ... # possibly others </code></pre> <p>But I recommend installing with the <code>--with-default-names</code> option whenever applicable.</p> <p>It seems <code>--with-default-names</code> is not applicable to the <code>coreutils</code> package, so</p> <pre><code>PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH" </code></pre> <p>always need to be applied.</p> <h3>Homebrew "caveats" and post-installation configuration</h3> <ul> <li><code>gdb</code></li> </ul> <p><code>gdb</code> requires special privileges to access Mach ports. You will need to codesign the binary. For instructions, see:</p> <p>http://sourceware.org/gdb/wiki/BuildingOnDarwin</p> <ul> <li> <p><code>openssl</code> and certificates</p> <pre><code> $ brew install wget ==&gt; Installing wget dependency: openssl ==&gt; Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2a-1.yosemite.bottle.1.tar.gz ######################################################################## 100.0% ==&gt; Pouring openssl-1.0.2a-1.yosemite.bottle.1.tar.gz ==&gt; Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash This formula is keg-only, which means it was not symlinked into /usr/local. macOS already provides this software and installing another version in parallel can cause all kinds of trouble. Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include ==&gt; Summary 🍺 /usr/local/Cellar/openssl/1.0.2a-1: 463 files, 18M ==&gt; Installing wget ==&gt; Downloading https://homebrew.bintray.com/bottles/wget-1.16.3.yosemite.bottle.tar.gz ######################################################################## 100.0% ==&gt; Pouring wget-1.16.3.yosemite.bottle.tar.gz 🍺 /usr/local/Cellar/wget/1.16.3: 9 files, 1.5M $ </code></pre></li> <li> <p>Git</p> <pre><code> $ brew install git ==&gt; Downloading https://homebrew.bintray.com/bottles/git-2.4.0.yosemite.bottle.tar.gz ######################################################################## 100.0% ==&gt; Pouring git-2.4.0.yosemite.bottle.tar.gz ==&gt; Caveats The macOS keychain credential helper has been installed to: /usr/local/bin/git-credential-osxkeychain The "contrib" directory has been installed to: /usr/local/share/git-core/contrib Bash completion has been installed to: /usr/local/etc/bash_completion.d zsh completion has been installed to: /usr/local/share/zsh/site-functions ==&gt; Summary 🍺 /usr/local/Cellar/git/2.4.0: 1368 files, 31M $ </code></pre></li> <li> <p><code>sqlite</code></p> <pre><code> $ brew install sqlite ==&gt; Installing subversion dependency: sqlite ==&gt; Downloading https://homebrew.bintray.com/bottles/sqlite-3.8.10.1.yosemite.bottle.tar.gz ######################################################################## 100.0% ==&gt; Pouring sqlite-3.8.10.1.yosemite.bottle.tar.gz ==&gt; Caveats This formula is keg-only, which means it was not symlinked into /usr/local. macOS already provides this software and installing another version in parallel can cause all kinds of trouble. macOS provides an older sqlite3. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables: LDFLAGS: -L/usr/local/opt/sqlite/lib CPPFLAGS: -I/usr/local/opt/sqlite/include ==&gt; Summary 🍺 /usr/local/Cellar/sqlite/3.8.10.1: 9 files, 2.8M </code></pre></li> </ul> <h2><code>svn</code></h2> <pre><code>$ brew install svn ==&gt; Installing subversion ==&gt; Downloading https://homebrew.bintray.com/bottles/subversion-1.8.13.yosemite.bottle.tar.gz ######################################################################## 100.0% ==&gt; Pouring subversion-1.8.13.yosemite.bottle.tar.gz ==&gt; Caveats svntools have been installed to: /usr/local/opt/subversion/libexec Bash completion has been installed to: /usr/local/etc/bash_completion.d ==&gt; Summary 🍺 /usr/local/Cellar/subversion/1.8.13: 116 files, 9.4M $ </code></pre> <h2>(Ubuntu) Linux</h2> <p>There are only some of the command-line utilities which are not usually already installed:</p> <pre><code>sudo apt-get install indent sudo apt-get install gnupg2 sudo apt-get install python-pip sudo pip install --upgrade pip setuptools </code></pre> <h2>References</h2> <ul> <li> https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/</li> </ul>