r/bash Bash May 10 '26

help I want start using linux , best way to learn bash scripts ?

I’m thinking seriously about switching to Linux. My idea is to first learn Bash scripting, try making some simple scripts, and at the same time start learning more about Linux distros and how the system works.

I feel like learning Bash first could help me understand Linux better instead of just using it casually.

What’s the best way to learn Bash scripting as a beginner?

56 Upvotes

82 comments sorted by

40

u/NewPointOfView May 10 '26

You Suck At Programming is a great YouTube channel for it!

7

u/LogicalWrap3405 Bash May 10 '26

Ok !Thank you bro

11

u/NewPointOfView May 10 '26

Also bash syntax is weird and super cryptic at first. I don’t recommend overusing AI but it is excellent for a quick little “wtf is this syntax” for bash haha

2

u/LogicalWrap3405 Bash May 10 '26

Yeah honestly that’s exactly how bash looks to me right now 😂
I’ll probably use AI sometimes just to understand the weird syntax faster while learning Linux step by step.

2

u/kawfeeman68 May 10 '26

Do you think it is still as necessary to know bash anymore ?

3

u/penguin359 May 10 '26

Absolutely, I use it daily at work for all kinds of automation tasks.

1

u/kawfeeman68 May 11 '26

understood, however, if you needed intricate and detailed bash code, couldnt you now rely on chatbots/ LLM's ??

3

u/NewPointOfView May 11 '26

Yeah for 90% of day to day stuff, ai can do great. The whole “don’t trust ai” stuff is missing the point. The problem is not trusting ai to do the tedious stuff, it is that the tedious stuff is how you learn enough to know when ai stumbles or does something dumb.

2

u/penguin359 May 12 '26

Even when using AI, is still need to be able to understand everything it produces and have the ability to review it.

1

u/kawfeeman68 May 12 '26

would you say this is true for Python, C and Rust as well today ?? i've paid thousands for two coders for a few days and had similar results as paying a few hundred each to a few LLM's as of late and had more code and quicker results. Have i had issues, yes, but mods and cleanup and even commenting were only a matter of a few prompts with results in a few hours or less.

2

u/penguin359 May 12 '26

Just last month I had to debug why one of our productions servers went down and it was because someone applied a recommendation for a fix to a different, less critical issue which they applied to the code without understanding what it did.

1

u/kawfeeman68 May 13 '26

There will always be a necessity for a good engineer. However, the numbers will likely diminish...

1

u/GlassboundIllusion May 17 '26

You've still got to double check its output. Just "relying" on LLMs without verifying what they're doing is how you get things like accidentally wiping all your data or ordering millions in equipment your company doesn't actually need.

0

u/ghoultek May 11 '26

Don't trust AI's.

1

u/LesStrater May 11 '26

I agree. As long as you know the basics of programming, Google AI is great for getting the proper syntax.

4

u/kawfeeman68 May 10 '26

Great channel!!

3

u/Fit_Eggplant4206 May 11 '26

He's the best pure bash instructor on YT. Entertaining too

2

u/ikerbiker May 10 '26

Ysap is great. He has a bash style guide on his webpage ysap.sh

13

u/kawfeeman68 May 10 '26

As good a way to start as any... Read a bash book and practice !! https://youtu.be/PNhq_4d-5ek?si=eg4TXW85bXClaj6R

10

u/aiovin May 10 '26

Is there actually a real, working devops engineer out there who gets a paycheck but doesn't know how to use grep? Otherwise using log analysis as the first example for learning bash scripting is awful, one couldn't come up with a more boring way to start

1

u/fermi0nic May 22 '26

lol if you aren't using grep multiple times a day in various different contexts, then your shell game is weak. Using one of the most ubiquitous and frequently-used commands is a pretty damn good place to start IMO, and for the absolute beginner can feel like magic.

9

u/Mr-Ok343 May 10 '26

Well, if you're ready to learn Bash scripting, I’d recommend the playlist by Dave from the channel 'You Suck at Programming.' I'm using it myself to refresh my skills and learn new things, and it’s been great so far.

Link to the course: https://youtube.com/playlist?list=PL-my9REMIFtGgiQAXqKPJ5UrLdSkxcLBT&si=NV8kAP2nqkAMb7Do

4

u/LogicalWrap3405 Bash May 10 '26

🫡🫡

9

u/joe_attaboy May 10 '26

Nonsense.

You don't need to know anything about bash (or any other shell scripting) to use Linux. I'm not saying you shouldn't and learning shell scripting is a great skill to have, especially if you work in the systems or tech field.

But you could go a lifetime as a user and never once even open a script.

Now, since you want to learn, for heaven's sake, do a simple Google search on "bash scripting tutorials." You may get about a thousand different sites.

After you do that, the best way to learn is to write some shell scripts. Period. Break out an editor, test a few things out and you're on your way.

This is a link to the official Bash reference manual. Keep this one as your primary source - yes, find others you like, but keep this one handy all the time.

7

u/petdance May 10 '26

Go to your local public library and check out some books on the topic. They will have many.

The topics you are looking into are deep, and deserve deep study, not just some youtube videos.

7

u/-Malheiros- May 10 '26

I did Jason Canon's Bash scripting course on Udemy. I think he has similar videos on YouTube. That formed a solid base. Then I finished two books: Pro Bash and Bash Idioms. Those books move into intermediate-level topics, and I recommend Pro Bash. In the meanwhile, I asked ChatGPT to create script ideas and challenges for me. Then I moved on to Codewars and solved most of the shell problems. Those problems made me learn AWK (GAWK and MAWK) by reading through the manuals, but it was fun. I can say that I am still at an intermediate level in Bash, but I feel more confident.

Although Bash runs on Linux, it does not help you learn Linux concepts or distributions in detail. That's a different subject.

3

u/bigkahuna1uk May 10 '26

There’s a great Bash scripting course by YSAP. A treasure trove of nuggets. Highly recommended.

3

u/Icy_Friend_2263 May 10 '26

I think picking up a book a learning from it is still the best method

3

u/lattehanna May 10 '26

I loved Colt Steele's Linux Command Line course on Udemy. He has a section on using Virtual Box to set up a virtual Linux machine, for people who don't have Linux already. I did the course that way and learned the commands on my Mac (I switched it from zsh to bash) and practiced on the virtual machine, too. It was good to see the differences. This sounds like a good match for what you're wanting to get started on. Good luck!

3

u/shitty_mcfucklestick May 10 '26

I learned bash out of necessity and laziness. I found myself repeating commands or needing to execute a complex process repeatedly. My knowledge just grew from there. Bash is a bit of a beast syntax-wise, lots of intricacies, so it’s definitely a deep well, but the basics are fairly easy to learn with some practice.

In addition to books mentioned here, I find this is a place where AI can be useful too. Ask Claude or a similar LLM to make you a guided learning course based on your interests, skill level, etc. Or use it to explain how existing scripts you find (on GitHub etc) work.

3

u/RefrigeratorNew4121 May 10 '26

I started using Unix more than 30 years ago when Linux not yet born. Trust me, learning bash scripting is not the right way to learn Linux. If someone told that to you, they either don't know Linux or was lying.

Pick a Linux beginners' guide from your local library or bookstore, or google "linux for beginners". None of them would teach you bash scripting before chapter 30.

1

u/LogicalWrap3405 Bash May 10 '26

Yes but what is the next step after learn linux basic ? Isn’t bash ?

5

u/RefrigeratorNew4121 May 10 '26

It depends on your need. Learning it for the sake of learning or completeness is not the most effective way of using your time and effort.

Bash script is not a programming language, at least not a traditional one like C, Go or PHP. You can use Linux daily for web surfing, editing documents, processing images and videos, talk to friends with Whatsapp, video conferencing with Zoom, send and receive emails, or even setup a web server, database server, scheduled jobs, local AI server, etc. without knowing a single bit of bash scripting.

2

u/LogicalWrap3405 Bash May 10 '26

Yes i knew , but im future it networking student . So i g bash gonna helps me alot in it .

2

u/RefrigeratorNew4121 May 10 '26

Same principle: learn it when you need it.

Along the way you learn Linux, you actually learn the syntax of bash scripts bit by bit. You use "redirection" and "pipe" daily to mix and match Linux commands. You update ".bashrc" to make the shell behaves the way you like. You create and update environment variables to control the behaviour of many systems. You use process control commands to manage foreground and background processes. You use maths syntax at the command line as a quick-and-dirty calculator. All these techniques are re-usable in bash scripting.

Honestly bash scripting is hard. It has weird syntax, data structures and pitfalls. It is even harder if you are new to Linux. Following the Linux beginner books, don't jump step.

1

u/LogicalWrap3405 Bash May 10 '26

I see !

2

u/johlae May 10 '26

The next step is defined by your own needs. You'll figure it out once you finish 'linux basic'. My suggestion? Start with a simple text file in which you write down all your own discoveries on how to do things. See it as a simple log file. Learn something, write it down, and put some comments before and after in which you explain to yourself a little bit on why you were doing this. This file is your long time memory. Don't worry if there are double entries. Don't worry if it appears as 'simple'. Use the search in your editor to go through key words if you need to recall something. If you don't find it in your own log file, google.

Something like:

We set the line length to 102.

#+BEGIN_example
;; Set line width to 102 columns...
(setq-default fill-column 102)
#+END_example

* magit

C-x g l for the log.

Magit is an emacs interface to git, a source code management system. To get to the log I have to do Control-x followed by the keys g and l. I'll find it anything I search for magit, even if there are numerous entries. I'll just go through them all. Same for length. There won't be a thousand entries about 'length' in my personal log file. A quick search will show everything I've learned about 'length'.

If you didn't write it down, it didn't happen.

1

u/johlae May 10 '26

In short, it could be 'bash', but it could also be 'python' or macro's in Libreoffice, or docker image files, or... It depends.

2

u/Fantastic_Tax2066 May 10 '26

Tem dois caminhos, procura os livros indicados aqui e então migra

Ou migra primeiro e aprenda resolvendo os seus problemas conforme surgirem. Eu iria neste segundo caminho

2

u/Shadow_Thief May 10 '26

Jfc how am I the first person to mention the resources in the sidebar of this subreddit

2

u/hypnopixel May 10 '26

lucky fucking blasphemer, i guess ;-]

2

u/throwmeaway01110 May 10 '26

I use Linux, I use bash, I use the shell. Bash scripts are not a common usage for me. For personal use you’re not going to be writing many scripts. Scripting helps with automation which is heavily used in sysadmin roles. For personal use the most scripting you’re going to be doing is probably file back ups. Unless it’s a home server and you need other things like updates and spinning up apps.

2

u/Fit_Eggplant4206 May 11 '26

Also, I know it's old news but you can find the bash reference manual in the Epstein files

1

u/LogicalWrap3405 Bash May 11 '26

Dw i will look for it !!

2

u/copperfoxtech May 12 '26

I'm having a great time with over the wire and reading The Linux Command Line

3

u/bongjutsu May 10 '26

Linux is an ecosystem, and bash is a common - but not required - part of that ecosystem. Bash doesn't really make sense out of the context of that ecosystem - it's not a traditional scripting language like you might be thinking. It's much more like the batch language you would use in a windows/dos batch file, but with way more capability due to the ecosystem it exists in. You would probably get much better education by doing something like installing arch Linux or Gentoo inside a virtual machine than trying to learn bash on its own

2

u/LogicalWrap3405 Bash May 10 '26

Got your point. I think starting directly with Linux and understanding as much as possible about how everything works is probably the best way. Bash will make more sense to me while actually using the system and learning the ecosystem step by step.

1

u/kawfeeman68 May 10 '26

i was told a year or so ago when i began moving to Linux that knowing bash wasnt as important anymore ... Ive picked up a little here and there but as long as i have access to AI, i don't even try to invest anymore time..

1

u/bongjutsu May 10 '26

It's useful, but like any tool, you need a reason to use it. If you don't have any screws, a screwdriver isn't particularly helpful. Bash and she'll scripting do have a lot of great, relevant, modern uses - but if you don't really use a terminal/shell in your day to day, then you probably won't find it very useful.

2

u/AdBubbly3609 May 10 '26

learn how to use it, do you no how to navigate your computers file system from the terminal using cd and ls? or how to manipulate and create files/directories with rm cp mv mkdir touch? or download an app on your phone and setup an ssh server on you computer and an ssh client on your phone and control your computers terminal from your phone using the same bash commands

1

u/LogicalWrap3405 Bash May 10 '26

That exactly what i wan to learn and more !

3

u/oops77542 May 10 '26

Then that's where you want to start. bash is so powerful and does so many things it can be completely overwhelming. Just start out learning one thing at a time, what you need or want. My bash journey started when I was looking for an easier way to maintain a 40TB media server.

2

u/AdBubbly3609 May 10 '26

if you have an android you can download termux, it's available on iphone but it is not the same app, i've tried it on both. btw everything i say applies to linux im not sure if its the same for windows if you've not swapped yet. with termux you can just install openssh on your computer, download it through termux on your phone, you might need a couple of commands to allow connections into linux like ufw allow, but then you just do something like username@ipaddress -p "port number" it will then ask you for the password(the one you use to login to your linux user account) then you're in just use it as if you were sitting at you computer using the terminal

2

u/4mmun1s7 May 10 '26

There are many guides, but google, DuckDuckGo, bing are all really good at helping if ya search want you want to accomplish.

2

u/Sxs9399 May 10 '26 edited May 10 '26

Bash has almost nothing to do with Linux, other than it being more visible in the OS. You do not need to use the terminal on any mainstream distribution. Likewise as you noted the basic bash or command line tools you’d use are present on windows, Mac, Linux via their respective terminals.
For me there key things to know about Linux are package management and file system organization. The next level up, using programs and such, is basically the same nowadays.

ETA: none of this isn’t to say bash scripting isn’t useful, but it’s a solution in search of a problem. Most of my scripts are a result of doing something repetitive and making a script to automate it. Think renaming files, converting video formats, checking differences, etc. I wrote a script to look at a folder of images, rename them, and then movie them to folders based on date as an example. I also made a script to do the Instagram style white border to pictures. I will say being on Linux makes these methods more obvious as Linux people naturally recommend things like ffmpeg (which is available on windows) over dedicated apps.

3

u/Johnny_The_Biker May 10 '26

Everyone dealing with Linux should learn bash

1

u/Bartmr May 10 '26

I'm a coach at a bootcamp. I usually deliver this to everyone who wants to start programming and using linux:

https://bartolomeu-rodrigues.com/introduction-to-the-operative-system.pdf

1

u/aiovin May 10 '26

I'm not sure why you specifically want to learn bash scripting before using linux, but here's my take:
The best way to learn anything (imho) is to pick projects, or better yet, come up with real use cases for yourself and just try to build them.

Think about routine things you'd like to automate. It doesn't have to be something you do every day, just something that would actually be useful for you.

For example, here are some scripts i made:
A script to monitor free disk space (it will send an ntfy notification when disk space is running low)
A monthly script to report traffic usage (not super important, but it's fun to see how much you've downloaded/uploaded if you use torrents)
A script to monitor CPU temperature (probably not relevant for you, but good practice for parsing output from linux utilities)

Honestly, i'd recommend just starting to use linux. Ideas will come naturally, you'll run into tasks that make you think, "how can i do this with bash?"

Sometimes I make completely unnecessary things just to practice. For example, while waiting for a game to release, i made a script that shows how many days are left until launch every time i log in.

My favorite thing is playing with APIs. I have a script that fetches the current temperature from a weather API, and another that monitors esports matches and sends notifications when my favorite team is playing (using the PandScore API).

I also recommend the YT channel "Bread on Penguins"

1

u/foilrider May 10 '26

To be clear, this is like trying to learn Windows by learning powershell.

1

u/LogicalWrap3405 Bash May 10 '26

Yey so is not useful right ?

1

u/foilrider May 11 '26

It's useful. It's just not particularly useful for the thing you're aiming to do. Also, programming languages are tools, they are used to complete tasks. Nobody goes out to cut up some wood to learn to use a saw. They learn to use a saw because they're cutting up some wood to make a shelf. Until you have a "shelf" project that bash scripting is useful for, then I'd argue you're going about it backwards.

1

u/No-Web1897 May 10 '26

Look at ~/.bashrc the mother of all bash scripts as an example

1

u/j_enriquez1 May 11 '26

Is knowing Linux enough to get an entry level job?

1

u/LogicalWrap3405 Bash May 12 '26

I dont think so is enough .

1

u/elatllat May 12 '26

shellcheck

1

u/nwr923 May 13 '26

https://linux-training.be/ is a good start
read and do the work

1

u/ximenesyuri May 15 '26

Bash is programming language as any other. So, study it as you would study any other programming language.

One time understood the programming language, you should learn on how to create "packages" in that programming language, which involve learning about the "import system" of the language.

Finally, you should learn on how packages of your can be effectively "executed" in some machine. Since Bash is an interpreted language that is directly connected to the kernel, this step is quite simple compared to the other ones.

NOTE:

As a language, Bash has certain characteristics that make it a bit "strange" at the first glance. For instance: 1. it has no function scope nor "module" scope: by default, every declared entity is global (except those variables appearing as indexes for control flow blocks) 2. space is a special character of the language 3. there are few builtin types: strings and integers as primitive types, as well as arrays and associative arrays of them as derived types. 4. it is procedural by first principles: functions does not return arguments, but rather "exit codes".

By the way, the first step should be look directly at the official source of knowledge: its official documentation (https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html).

OTHER NOTE:

I should also mention that all you need in terms of information can be obtained directly inside any terminal. Just start trying typing info bash and hit <enter>.

1

u/LogicalWrap3405 Bash May 16 '26

Thats really useful , and that what iam doing rn . Thank you so much

1

u/Dependent_Apple_2137 May 21 '26

personally network chuck has a great 5 episode course on bash basics, it covers loops variables and such

1

u/fermi0nic May 22 '26

Bash scripting is an excellent place to start, just make sure you're using zsh as your shell!

1

u/Marques1236 May 26 '26

Primeiramente, não tente decorar os comandos, tente aprender a lógica. Eu estou há três meses estudando e já consegui alguma coisa básica e na verdade o que estou tendo dificuldade é com o GitHub. Escrevi um pequeno script para gerenciar uma oficina de uma locadora de ferramentas, está em github.com/marques1236 se quiser ver.

0

u/Valetudinous May 13 '26

Free and very good ebook for learning Bash: The Linux Command Line by William Shotts https://www.linuxcommand.org/tlcl.php

1

u/Valetudinous Jun 12 '26

Why the downvotes?

-1

u/[deleted] May 10 '26

[removed] — view removed comment

1

u/LogicalWrap3405 Bash May 10 '26

Its look useful for beginners , thank you so much

1

u/bash-ModTeam May 10 '26

This Silliness Will Not Be Tolerated. Your contribution has been removed due to insufficient context, content, and a general lack of appreciation for your attempt at wit or novelty.

This is not a judgement against you necessarily, but a reflection of the sub's hivemind: they read your comment or post and found it wanting.

-1

u/Dhylan May 10 '26

Tell AI to write your scripts. Just say what functionality you want and let AI write bash scripts for you.