Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

Resources for learning bash/shell scripting in GNU/Linux

Mike Turcotte-McCusker
Jan 1, 2018
Linux
|
23

There is a stigma around the word Linux, where people generally envision people with glasses, beards, and look like a hippy programmer. Funny enough, this perfectly describes Richard Stallman, the creator of GNU, the actual operating system that we simply refer to as ‘Linux’ nowadays (much to his distaste.)

However, part of this stigma, is also that GNU/Linux users are constantly glued to terminals, hacking away code constantly to run their operating system. This once upon a time wasn’t too far off, but nowadays most users may never even see the terminal.

However, those who do wish to dive in deeper, and really see the true power behind using a CLI, may wish to learn shell programming / scripting. The applications of doing so, are virtually boundless; from automating to maintenance.

Learnshell

However, self-teaching scripting can be tedious and sometimes confusing, if you don’t know where to begin, or have some kind guidance. There’s quite a number of resources for learning various languages, but my personal favourite for Shell, is https://www.learnshell.org/

Like other sites such as https://codeacademy.com, Learnshell uses an interactive teaching method where users are taught a lesson and forced to utilize what they learn to complete objectives.

Learnshell also has a number of other languages available, such as:

  • C
  • C++
  • C#
  • Python
  • Java
  • Go
  • HTML & CSS
  • PHP
  • Perl
  • Ruby

However, I can only attest to having used the website for shell scripting personally, I can say that I am interested in checking out the C tutorials as well.

The Shell programming section of the site sorts tutorials in basic and advanced groups. You learn about variables, basic operators and decision making in the basic section, and about advanced concepts such as regular expressions, process substitution or input parameter parsing.

Another great resource for learning to script, focusing specifically on bash scripting, is http://www.bash.academy/

While not using the same live interactivity as a couple of sites previously mentioned, the bash academy is far more in-depth with explanations and lessons taught. Some could view this as information overload, others may love to learn all of the intricate details. Regardless, it is definitely a place worth checking out if you’re interesting learning the most common and native scripting (arguably) for your GNU/Linux system.

With that said, for those of you about to take the plunge and start heading deeper into the magic of the command line, its a bit of a learning curve if you don’t have a background in programming, but it is definitely worth the effort! Good luck!

Summary
Resources for learning bash/shell scripting in GNU/Linux
Article Name
Resources for learning bash/shell scripting in GNU/Linux
Description
Mike takes a look at several free interactive learning resources that teach you bash/shell scripting in GNU/Linux.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Previous Post: «
Next Post: «

Comments

  1. Tsreb said on January 25, 2018 at 3:22 pm
    Reply

    I’ve been playing with Linux for the last year. Made the switch with my Laptop because the upgrade to Windows 10 caused my laptop to become almost unusable. I had a friend introduce me to Linux and with the installation of Mint, was able to give my laptop a new life. It is faster and fun to use again.

    People, the CLI is only one interface that can be used to access Linux. It is the same as the terminal (MAC) and the DOS prompt (Microsoft) and theoretically you do not have to know any commands to use Linux. But by learning it (like learning terminal commands and DOS commands) you can have more control/options on you OS.

    To me the best thing about Linux is the variety of Presentations that are offered as well as the ability to find a distro that will work on most machine configurations. Also, another benefit is the fact that most software is FREE (including the OS) and that in many cases have more functionality then the MS or OSX alternatives.

  2. PJ in FL said on January 10, 2018 at 1:47 am
    Reply

    Personal experience – loaded Mint 18.3 xcfe on SOs computer in a dual boot configuration with Win 10. M$ did a drive-by “upgrade” and made her laptop, an older HP, unusable for most of her usage – browsing, on-line email, Youtube and local videos. Most HD files were unplayable and even lower resolution video was jumpy.

    Installed Mint with Firefox and SMPlayer in a 10GB partition (Windows is in a 300GB partition) and she hasn’t looked back. There were some issues that needed technical solutions, but once I got past the “4 primary partition” limitation, the other issues were fixed by a quick session in the Mint chat room. Once I convert another PC over and make sure I can run Excel in Wine or some other method I’ll give M$ the salute it deserves.

    I’ve been writing BAT and CMD files since DOS 1.0, and lately VBS if I feel frisky, so the CLI wasn’t going to be an issue. Most of the time I’d copy commands verbatim from the chat room and paste in the CLI and run. No muss, no fuss.

    Compared to trying to use Powershell there’s no comparison. Whoever came up with that should be hung next to the Win 8 developers. Too bad no one has adopted REXX since it’s brief time as the OS/2 scripting host, but I’m dating myself!

  3. STech said on January 4, 2018 at 4:18 pm
    Reply

    Great resources for beginners.
    And also there is Stack Overflow for quick help.
    Thanks Mike

    1. lushkava said on January 4, 2018 at 5:58 pm
      Reply

      @STech: Take answers from Stack Overflow with a pinch of salt, as they tend to be of poor quality for questions concerning shell scripting. There’s even a ‘factoid’ concerning this in the #bash IRC channel:

      “Like virtually every other web site you find via Google, StackOverflow is chock full of wrong answers. Verify everything you read there before using it”

      Unfortunately, this is generally true. While there are a handful of posters that provide good answers, they have a disturbing tendency to head towards the bottom of the heap. Exercise caution – and check your code with shellcheck.

  4. Sithadmin said on January 2, 2018 at 2:15 pm
    Reply

    This article is incomplete without mentioning the bash wiki, subreddit, and IRC channel. Bash has a great support community, as long as you show some effort.

  5. Geoff said on January 2, 2018 at 1:34 am
    Reply

    As someone who has been using Linux for about 10 years now but regrettably has only in the last couple years really started to learn about scripting beyond basic alias-esque typing-reduction-shortcuts, I really appreciate this post, thanks a lot!

    Using a bash script I wrote with one if statement, my HTPC sets the display refresh rate on my TV to 24Hz when the video I’m about to play is 23.976 or 24 fps and 60Hz for everything else (sadly those are the only 2 usable progressive refresh rates my tv supports or I’d have the script setting to 50Hz and 25Hz when appropriate also)

    I’ve got another that’s mostly just if statements and a lot of variables using the date command that downloads podcasts of radio shows on a local college station. It detects when it’s downloaded the same file as the previous week (when the DJs are slow to post) and deletes it before scheduling a later attempt, or otherwise it moves the file and renames it to include the airdate.

    I just wish I had more tasks that needed automating so I had a reason to figure out more. The links in the article look like just the ticket!

    Ah, but for the trolls, sigh. Everyone should embrace the CLI, it’s popular with people who have taken the time learn anything about it because it’s powerful as all get out. And in any case, pretty sure the article was titled “resources for learning bash/shell scripting” and not “resource for all new linux users, you better have this down cold before you even consider loading a livecd, you clod” for a reason.

  6. lushkava said on January 1, 2018 at 7:10 pm
    Reply

    +1 for recommending bash.academy (lhunath is a genuine expert). I would also recommend Greg’s Wiki at http://mywiki.wooledge.org/BashGuide, along with http://mywiki.wooledge.org/BashFAQ. Indeed, the guide located at the wiki is largely lhunath’s work and, thus, very similar to guide.bash.academy which, for now, remains a work in progress.

    Further, those that want to understand the particulars of the standard POSIX sh should study http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html and http://mywiki.wooledge.org/BashGuide/Practices#Choose_Your_Shell.

    Last but not least, https://www.shellcheck.net/ is an outstanding tool for linting and critiquing sh/bash code.

  7. Trenton Cain said on January 1, 2018 at 5:26 pm
    Reply

    Thanks for the insight. With expanding my DevOps endeavors, I need to be proficient in both Python and Bash Scripting. You helped out tremendously to start the year off. Happy New Years!!!

  8. Estelle99 said on January 1, 2018 at 5:05 pm
    Reply

    This is just my opinon. I am running Win8.1 without a Microsoft account plus Classic Shell for the UI.
    To keep it short: I can do pretty much what I want, have reasonable control over my pc and most of all it works for me and I feel comfortable using it.

    Then Win10 appeared. Right from the beginning I felt very uneasy about the way MS was pushing it. I started croaking like many others but also became curious so I tried the Home and Pro version. And went back to 8.1. Why ? After working with Win10 for a while I did not trust it and had very little control. I did not find any reasons to ditch Win8.1 for this questionable “downgrade”. You may have a different view and I am glad if it works for you.

    Me big mouth started shouting “I change to Linux”. I did. I used Ubuntu LTS and Mint Cinnamon. And run into major printer problems which turned the printer into a heavy piece of paper weight. I used the recommended forums, etc. Only to find out that 5 people can have 119 opinions about one topic. On top of that some of the advice given was incomplete or plain wrong. The way advice was presented often was ghastly and indigestible for me. Too technical, full of gaps and a tremendous boondoggle when searching for a solution. Not always, but too often. The printer problem is only an example, there were more probs but I don’t want to write a novel.

    I ditched Linux because of the major timewaste when looking for solutions. I got extremely tired and frustrated about wrong and incomplete advice and the way it is presented. Don’t get me wrong. I think Linux Mint and Ubuntu LTS are pretty good programs (use it with Wine for Win software) and perform mostly without problems. But if you run into one and have to rely on solutions from the web you may end up in the bughouse. Happy New Year to all of you.

    1. Jonathan said on January 1, 2018 at 9:52 pm
      Reply

      Why “linux” has to provide out of the box a driver for your printer? Ask the manufacturer of your printer for linux drivers.I don’t think microsoft creates themselves drivers for any printer out there. It’s not a linux problem that you chose to buy a printer that didn’t have linux drivers.
      I have a new pc, built in 2017 and everything works great out of the box. No need to install any driver myself. I chose to include hardware with linux drivers.
      I switched to Ubuntu in 2017 from Windows 7. It’s the best thing I did in a long time. Everything works better and I finally I “own” my pc.

      1. MdN said on January 2, 2018 at 3:52 pm
        Reply

        Let’s not mention the instances when a Windows 10 update would break the support for Epson dot matrix printers or home network printers, OK?

      2. Jonathan said on January 2, 2018 at 8:47 am
        Reply

        Excuse me? You complained that various people on forums spent their free time trying to help you and they got nothing but disrespect from you. I have never seen people basically posting that Windows doesn’t work because their current printer doesn’t work ok. These are FUD posts trying to scare people that linux is hard, it’s not hard at all. And because it doesn’t work for you does not automatically imply it won’t work for everybody else. Live with it. I don’t enjoy to be so harsh but this was necessary.

      3. estelle99 said on January 2, 2018 at 7:21 am
        Reply

        What is wrong with you ? I never said Linux has to provide a driver for my printer, please improve your reading skills. And because it works for you does not automatically imply it will work for everybody else. Live with it. I don’t enjoy to be so harsh but this was necessary.

  9. Mark Hazard said on January 1, 2018 at 2:06 pm
    Reply

    I agree with the other two posters.

  10. basicuser said on January 1, 2018 at 2:02 pm
    Reply

    Agree with John C. about Linux needing to model main stream OS’s ability to point-and-click to be accepted by the great unwashed masses. Command line tweaking can come later.

    As the world’s worst typest, command lines are tedious at best. I also don’t give a hoot about what’s under the hood in that detail. My approach in moving to a Linux distro (using a thumb drive with Mint 17.1 now) is to model the set up of software in Win 7 as closely as possible. Using the command line is my last choice to make changes. I do however, read and store articles about Linux to learn and understand how to best use the system.

    Thanks for the information and please keep it coming.

    All the best for the New Year.

  11. John C. said on January 1, 2018 at 12:50 pm
    Reply

    No… no… I’ll pass. If Linux is ever to succeed as a worthy alternative to the privacy-raping abortion that is Windows 10, it’s going to have to work on making itself far more user friendly and welcoming to those attempting to make the transition from M$ and its “operating system-like products”.

    For the most part (except for having written a few batch files) I gave up on command line interfaces with MS-DOS 6.22.

    If there’s one thing that definitely puts off potential Linux users, it’s people telling them to embrace a CLI. Consider that most people are addicted to their smart phones and are going to perceive that CLI commands are too much like programming. The movie “Idiocracy” explains why this is.

    Others may disagree with my stance, but facts are facts. Linux programmers should be moving away from the CLI, not wasting their time attempting to convince others to embrace it.

    1. Alan Robertson said on January 2, 2018 at 7:21 pm
      Reply

      It really depends on how comfortable you are with the OS – Linux Terminal / Microsoft Power Shell are useful tools, but to be honest you don’t need the terminal these days in Linux for day to day usage. Even my technophobic mother can run Linux Mint. That said a lot of Linux users choose to do things via the terminal as you get more finite control over many things – GUI’s are great for ease of use but they don’t allow for full control of everything. It’s kind of like the Registry in Windows – you don’t have to edit entries, but if you choose to do so it does give you much more control over the OS. Some people are comfortable doing this and others are not – it’s good to have that choice in Linux.

    2. Jonathan said on January 1, 2018 at 10:00 pm
      Reply

      I switched to Ubuntu the last months and I haven’t touched CLI yet. I can install anything I want from the software center, this is what I keep hearing most people use CLI for.
      Chrome wasn’t available but I downloaded the deb file from chrome’s site.
      In fact it’s easier to install software than Windows. At least Microsoft is trying to make it easier lately with Windows Store.
      I can also tweak any setting I want from ubuntu settings, I never touched CLI for anything.

    3. lushkava said on January 1, 2018 at 7:48 pm
      Reply

      > No… no… I’ll pass. If Linux is ever to succeed as a worthy alternative to the privacy-raping abortion that is Windows 10, it’s going to have to work on making itself far more user friendly and welcoming to those attempting to make the transition from M$ and its “operating system-like products”.

      This is a false dichotomy. Enhancing the usability of Linux in its capacity as a desktop platform – in which respect I agree that it is unworthy – is not a goal that is mutually exclusive to the continued existence of the terminal emulator and shell. Is the usability of macOS diminished by having a fully-featured terminal emulator and bash included?

      > For the most part (except for having written a few batch files) I gave up on command line interfaces with MS-DOS 6.22.

      Good for you.

      > If there’s one thing that definitely puts off potential Linux users, it’s people telling them to embrace a CLI. Consider that most people are addicted to their smart phones and are going to perceive that CLI commands are too much like programming. The movie “Idiocracy” explains why this is.

      I’m detecting mixed messages here. Firstly, should Mike refrain from posting articles that are of interest to those who want to learn how to better use the shell, because you think that it somehow deters the advancement of GNU/Linux as an appealing desktop platform? If so, that would seem rather presumptuous. I work with Linux professionally, yet have no interest whatsoever in using it as a desktop. Would I then have a mandate to comment on Mike’s other articles – most of which do not interest me – stating that desktop LInux is a waste of time and a deterrent to its continued adoption for the numerous other purposes to which it is (arguably) better suited? No, I would not.

      Secondly, do you support the continued encroachment of this “idiocracy” that you refer to? What exactly is wrong with something appearing to be “too much like programming”? Is Android somehow harmed by the presence of, say, Termux in the Play Store? And how do you think all of this hardware and software is engineered, designed and assembled in the first place? Or perhaps you would prefer that we are all relegated to being content consumers, save for some as-yet unspecified elite who still have free reign to pursue their interests, whatever they may be.

      > Others may disagree with my stance, but facts are facts. Linux programmers should be moving away from the CLI, not wasting their time attempting to convince others to embrace it.

      Putting aside the entirely unsubstantiated premise that informs your rather haughty opinion, I don’t think Mike was trying to convince anyone to embrace anything. Here’s a fact: some people are – and will continue to be – interested in this kind of thing, whether you like it or not. The Shell Command Language and standard utilities are not going anywhere.

      1. Jody Thornton said on January 2, 2018 at 3:26 am
        Reply

        I never thought that John was quoting or paraphrasing Mike; rather he was just drawing from an opinion.

        If average Joe that is familiar with Windows is to be convinced of using an alternate, it needs to be an easy to use graphical experience. It needs to be intuitive. But many Linux distros are like that (Puppy distros certainly are)

    4. Gerard said on January 1, 2018 at 3:09 pm
      Reply

      John C., from the first two paragraphs: “There is a stigma around the word Linux […] part of this stigma, is also that GNU/Linux users are constantly glued to terminals, hacking away code constantly to run their operating system. This once upon a time wasn’t too far off, but nowadays most users may never even see the terminal.”
      User-friendly Linux distributions, such as for example Linux Mint, have been around for quite some time now. They can be used without CLI commands and are safer and more reliable operating systems than MS Windows. However, it may take new users some time to get used to a Linux distribution. After all Linux isn’t MS Windows, fortunately.
      Inquisitive users may want to explore the various possibilities of a Linux OS. They may discover that certain things are done quicker from the terminal (CLI). Besides, as the author puts it in the third paragraph: “those who do wish to dive in deeper, and really see the true power behind using a CLI, may wish to learn shell programming / scripting.” However, you don’t have to “dive in deeper”.

    5. Bill said on January 1, 2018 at 2:08 pm
      Reply

      I agree with John. Decades went by and Linux still with that dependency nightmare and lacks a standard to configure things. Feels like everything still beta forever in linux.

      console in windows is a plus, improves user capabilities.
      console in linux is a must to do anything else other than browse the internet.

      lets give it 10 more years and see if linux still beta :)

  12. Gavin said on January 1, 2018 at 10:06 am
    Reply

    Just to let you know, the link to Code Academy is broken – seems it needs the www prefix.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.