Saturday, May 28, 2022

[SOLVED] Running Linux shell on OS X

Issue

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?


Solution

It depends on your use specific use case:

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

    • 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 and above), install Docker and then install, e.g., an Ubuntu image (docker pull ubuntu).

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


Answered By - mklement0
Answer Checked By - David Marino (WPSolving Volunteer)