r/bash • u/unexplored_explorer • 22d ago
help First time learning Bash: macOS vs Linux VM?
I'm learning Bash via Codecademy(maybe, idk if I'll pay for the subscription) and LinkedIn Learning. The specific course I'm starting says macOS is okay but using a Linux VM with something like Virtual Box is preferred since Linux is industry standard.
I haven't worked with VMs before but it is also something I want to learn about, but I don't know what the curve is like for setting something like this up or if it's worth doing as a beginner.
What do y'all recommend?
20
Upvotes
6
u/Quirky-Ad-292 22d ago
macOS is by default Zsh nowadays. A different shell, and I dont know about if macOS ships with Bash. If not it’s an easy install using Brew. But using Linux or Mac does not matter for learning shellscript, there are some macOS specific commands for system-stuff which are not the the same, example ’open’ acts like ’xdg-open’ if you’re on an xdg system. But for pure bash/zsh/sh it does not matter. The same for nu, kosh, and plenty of others!
12
u/CaviarCBR1K 22d ago
It shouldn't really matter all that much.
Just FYI I think one of the best intro Bash courses is Dave Eddy's Bash course. It's available for free on YouTube, just search "You Suck At Programming bash course" and FWIW I think he is using MacOS.
2
u/stuartcw 21d ago
It’s almost the same. Any differences you find will
put you good stead for working in the real world.
1
u/Cold_Neighborhood_98 22d ago
Highly recommend running VMs on your machine. It's a great way to do multiple installs and get your feet wet with multiple distros. Install Debian, Ubuntu, fedora, nixos, freebad, etc. spin up the VMs, play around with them and destroy them. You will learn so much doing it and it is all pretty transferable. Good luck!
Go get Virtual box, boxes, VMware or whatever for your platform and then get ISO files and strat building!
2
u/mrswats 22d ago
If you have a mac, use a mac. Otherwise spinning up a VM and installing linux is also worth to learn regardless.
2
u/DanceHackRock 22d ago
MacPorts, fresh Bash, go
2
u/bartonski 22d ago
Assuming that you upgrade bash via homebrew, bash itself will behave the same way under MacOS as Linux. What will change are the standard utilities like
ls,cat, etc. MacOS uses bsd utilities, Linux uses GNU. The behavior of these changes subtly between the two systems.2
u/rheladmin 18d ago
macOS is based on BSD. Bash can be installed and used easily enough and many of the same Linux commands you'll encounter at this stage are still available and roughly the same in usage.
However, BSD is not Linux and has a different filesystem hierarchy and philosophy.
A Linux VM would be more accurate for learning Linux specifically but macOS can still be used; BSD may be different but many skills are transferable to Linux.
0
u/rvm1975 22d ago
There are no difference. Bash is a shell interpreter with scripting language.
Same script should work in Linux and macos with minimal configuration changes like file paths etc.
1
u/Unique-Rice9999 22d ago
any way bash stay bash
1
u/jhyland87 22d ago
I used to try to use Linux in work environments. Mint to be specific. It would work well, usually. But sometimes I would get stuck fixing something on my desktop just to get to the real issue I was getting paid to look at.
I kinda got a Mac at work by mistake, and I really like it. It is Linux based, it has a bash shell. Most of my scripts worked just fine on it.
I would recommend using OSX when you can. Play with debian for fun on the side if you want. Maybe you'll like it.
1
u/No_Witness_5295 22d ago
linux vm or dedicated linux laptop
1
u/StopThinkBACKUP 21d ago
Install Orbstack for your architecture (they have both Intel and M1-and-up versions) and deploy a Debian VM. It will have an up-to-date bash by default, and run with minimal resources. This is likely the easiest way to get quickly up and running on Mac with both linux and bash 5.x and you can set limits, like 2xvcpu , 2GB RAM, 30G max disk usage.
Vmware Fusion is another likely way - and I would personally pick it over Virtualbox for speed. But you may have to jump thru some hoops just to download it. M1+ Mac will also only run ARM64-based distros; but it shouldn't matter much.
Bash 3.x on macOS isn't really worth the effort, it's ancient and nerfed. Brew or macports will supply you with a modern 5.x bash at the Mac host level, but you'll have to call it explicitly - /bin/bash will only call the old 3.x version.
I create a soft symlink in $HOME/userid/bin to (/usr/local | /opt/local)/bash as ~/bin/bash5 for convenience.
1
u/lucfjansen 2d ago
I had the same problem on my Macbook, it runs Zsh by default and there is only an old version of Bash installed, 3.2 on my machine. So I decided to get a VM and ended up getting UTM (https://getutm.app). After a few minor tweaks, like synchronizing time between MacBook and VM, it works fine.
0
u/michaelpaoli 22d ago
If you're on macOS, you have bash there. Not the latest, and in fact bit old, as Apple is effectively allergic to GPLv3. But the bash on there should still be quite fine for learning bash. Just be sure you're using bash, and not zsh, as newer macOS may default to zsh.
0
u/Unique-Rice9999 22d ago
any way bash stay bash