r/bash • • 21d 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

37 comments sorted by

2

u/stuartcw 20d ago

It’s almost the same. Any differences you find will
put you good stead for working in the real world.

1

u/unexplored_explorer 20d ago

Sounds good, thank you!

12

u/CaviarCBR1K 21d 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.

3

u/unexplored_explorer 21d ago

Thank you, I'll check it out!

9

u/gncnaxb 21d ago

YSAP is great. Dave Eddy gets my vote as well.

8

u/MyManCbert 21d ago

Plus One for Bash Jesus

2

u/bahamas10_ 15d ago

i am, and thank you! in the course it is all done on macOS but i installed bash 5 via homebrew. parts of it were done on linux but i specifically mention when i switch (usually to illustrate and operating system difference).

so, im biased, but i agree that my course is the best 😂

2

u/CaviarCBR1K 15d ago

Wow I didn't expect to get a reply from the man himself!

Thank you so much for everything you do. I watched your Bash course and it opened up a whole new world for me. I'm pursuing a career in Linux system administration and your course has been an invaluable resource. I recommend it to anyone who is interested in getting a better understanding of Bash.

1

u/bahamas10_ 13d ago

that’s awesome! i’m glad to hear it and i wish you luck in your career. i’m glad my course could help

6

u/Quirky-Ad-292 21d 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!

7

u/MyManCbert 21d ago

macOS ships with an ancient version of bash. Going the homebrew route is totally the way to go for a modern version.

My only (mild) disagreement is that it does matter in certain situations. Is OP likely to run into those while just learning? Probably not. But there are definitely enough things that don’t translate across shells that knowing the differences and “gotchas” down the line will be important for portability.

All in all I agree with you though- OP can learn and make progress on either, then learn the differences and nuances as they run into them.

1

u/mfnalex 21d ago

Yeah mac‘s bash is ancient

1

u/Cold_Neighborhood_98 21d 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!

0

u/unexplored_explorer 21d ago

For just starting out, what distro would you recommend? I asked around in other spaces and people were saying Ubuntu but idk how much of a difference it would make

2

u/ninhaomah 21d ago

Pls don't mix software with OS

1

u/unexplored_explorer 21d ago

Could you clarify what you mean?

3

u/ninhaomah 21d ago

" I asked around in other spaces and people were saying Ubuntu but idk how much of a difference it would make"

This. Ubuntu is an OS , well a distribution of GNU/Linux if you want to be technical, and bash is one of many shells.

It doesn't matter which distro you used , bash is bash.

If I were to ask you I want to use Adobe Reader but I am not sure whether there will be a difference if I use it on Windows 10 or 11 , what would you say ?

Same thing.

1

u/Cold_Neighborhood_98 21d ago

Ubuntu is fine. Just get into there and get your hands dirty. As soon as you have installed an OS a few times and feel comfortable, then go install another one. Try to set a little task for yourself. Install the OS, then automate setting it up the way you like it with bash, then download a program. Actually as others have mentioned, Dave Eddy and "you suck at programming" is a great reference. Watch some of his stuff and maybe follow along and try to build things.

2

u/mrswats 21d 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 21d ago

MacPorts, fresh Bash, go

2

u/bartonski 21d 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 17d 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 21d 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/unexplored_explorer 21d ago

Right, though since Apple doesn’t use GPLv3 and the default is zsh, it wouldn’t be the most up to date version(?)

1

u/colemaker360 21d ago

You are correct. The old Bash shipped with macOS is a problem, but it’s easily solved by installing a modern bash version via Homebrew. Depending on the course, might also find that the bash examples assume GNU tools, which have subtly different flags and behaviors from the BSD tools Macs ship with. That’s easily solved by installing GNU core utils via Homebrew as well, but at that point you might decide that a Linux environment is simpler, in which case I highly recommend Lima (again, easily installed with Homebrew). Lima is a full CLI Linux on Mac without the hassle of setting up a whole VM to get it.

1

u/Unique-Rice9999 21d ago

any way bash stay bash

1

u/jhyland87 21d 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 21d ago

linux vm or dedicated linux laptop

1

u/StopThinkBACKUP 20d 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 1d 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 21d 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.

1

u/unexplored_explorer 21d ago

My machine defaults to zsh so I just manually switch it to bash.

1

u/michaelpaoli 21d ago

Yep, simply execute bash, or if you want, can change your login shell to bash.

1

u/unexplored_explorer 21d ago

Sounds good. Would this be the same for writing a script file?

2

u/michaelpaoli 21d ago

Yup. Script file specifies its interpreter, so not a problem.

1

u/jhyland87 21d ago

Just run chsh -s /bin/bash

0

u/Unique-Rice9999 21d ago

any way bash stay bash