Behdad Ahmadi Behdad Ahmadi - 4 months ago 5x
Bash Question

Running Linux shell on OS X

I want some applications to run on my OS X. But they cant be ran due to they are only for Linux. How can I have a Linux shell on my OS X? I mean how can I have a seperate Linux shell and a OS X terminal on OS X?


It depends on your use specific use case:

  • To run GNU utilities (as found on Linux systems) alongside the mostly BSD-based OS X utilities on OS X, install them via Homebrew; note that installing alongside entails that the GNU utility names are g-prefixed to avoid shadowin the stock OS X utilities; e.g., GNU ls is installed as gls; also note that OS X's Bash is still v3.x:

    • brew install coreutils ... most of the GNU utilities (installed g-prefixed)
    • brew install gawk ... GNU Awk (installed as gawk)
    • brew install findutils ... the find utliity (installed as gfind)
    • brew install gnu-sed ... GNU Sed (installed as gsed)
  • To run commands in an isolated, bona fide Linux environment inside a VM (using Bash v4.x), install Docker and then install, e.g., an Ubuntu image (docker pull ubuntu).

    • With the Docker environment loaded (open application Docker QuickStart, you can then run docker run -it ubuntu bash to enter an interactive Bash shell on Linux.