I'm a Staff Software Engineer at Cisco. I specialize in Python and Go, building functional, practical, and maintainable web systems leveraging Kubernetes and the cloud. Blog opinions are my own.
This is awesome! I love reading different people's approaches to teaching something to a beginner. I like that you took the time to explain what a shell is and why it's useful, because I didn't get that when someone showed me a shell for the first time and I wish I would have.
A couple gotchas to add for newbies:
When you're setting variables, make sure you don't have spaces on either side of the equals sign. my_var="Soup" is right, but my_var = "Soup" will cause errors. The bash shell uses spaces to separate commands from their arguments and split strings into lists, so doing it the second way will make it think you're trying to run the my_var command with first argument "=" and second argument "Soup".
I've read a couple of things including the Bash manual that say that, in general, using aliases should be avoided in preference to using functions pretty much always. That being said, there's no Bash police, so do what works for you, especially if you're not sharing your scripts with anybody.
Thanks for the feedback! Good point about the variable names, this article is a pretty broad overview so its no surprise I missed a few details like that. But they, I can always write a few follow-up pieces too.
I agree about it being good to explain why the Shell matters. I think that's actually the most important detail for me, since in the start when I researched it, there's no shortage of guides about how to use it. But until I really understood the why with the Pragmatic Programmer, I never saw why it mattered so much to stick through the learning process and bring that all back to my career. That's likely the part of the article I'd have wanted the most for my past self haha.
I'm a Staff Software Engineer at Cisco. I specialize in Python and Go, building functional, practical, and maintainable web systems leveraging Kubernetes and the cloud. Blog opinions are my own.
I'm a Unix nerd, through-and-through. I love the Mac. It's a great Unix system. I've heard it has a GUI too, but I stick with Terminal and bash. GUI is probably just a fad.
It took me a very long time before I started using that, but 90% of the time I'm going to ls after a cd. And because I'm silly, I end up ls'ing twice pretty often...
"Vim is, at its core, a text-editor. It's built into the Shell"
This isn't true (that Vim is built into the Shell). Vim might be in a directory contained in your PATH variable, but it's not built into the shell. (Note that I don't capitalize "shell", and I don't know why you do, but that's quibbling.)
alias bashrc='vim "$HOME/.bashrc" && . "$HOME/.bashrc"'
alias ll='ls -l'
alias mv='mv -i'
alias header='curl -s -D-'
alias myIP='ip route get 8.8.8.8 | awk '\''{print $NF, "GW", $3; exit}'\'''
Coders need the Shell to do their job best. It's not going anywhere. No matter how uncomfortable you are in the start, take a deep breath and start using it
Super great article, as someone who loved using GUI's I was pretty against learning terminal at first until I saw how powerful and necessary it was to becoming a Web Developer.
I felt the same for the start of my career too. For git source control I kept using SourceTree due to its GUI until I saw I was missing out on so much of its functionality that way.
Worth mentioning that Bash is the default shell of most Linux distributions. Given Linux is the most popular operating system in the world, and that Bash is available on Mac and Windows too, it's definitely worth learning.
to .bash_profile to switch default editor to Nano.
Nano maybe is less powerful but much more intuitive for new bash users (to be honest I still use it and don't want invest my time into vim). And another thing that it is almost on all linux distributions as I know so you don't have to switch from nano editor on your local machine to vim on remote instances
As a desktop OS, I've tried Yellow Dog Linux, DEC Alpha Tru64 UNIX, and Solaris. (By "desktop" I assume you mean it uses KDE or Gnome or somesuch, and is GUI based with a mouse.)
As a terminal-style OS, I've used Microsoft Xenix. (That was before Xenix was spun off into SCO... and we all know how that story ends.)
I've not used OpenBSD nor FreeBSD. But since I'm a Theo de Raadt fanboy, well OpenBSD is more my bag. On a lark, I have used Darwin for about a week, which owes some lineage to FreeBSD.
All that being said, I also have a warm spot in my heart for Amiga. I am sometimes tempted to get the latest Amiga -- currently A-EON's AmigaOne X5000. But then I open my wallet and see the tumbleweeds blow out of it.
I've used the shell quite a bit out of necessity, but this high-level overview has done wonders for bringing my existing knowledge together as well as making me want to learn more!
Hey! I'm Dan!
I have been coding professionally for over 10 years and have had an interest in cybersecurity for equally as long!
I love learning new stuff and helping others
Location
Brighton / London, UK
Education
Edinburgh Napier (Postgrad Cert Advanced Security & Digital Forensics)
Very simple and to the point, funny that I've been using a linux shell for 27 years now but I actually took the time to read your article just to see how you did! I guess you drew in my interest somehow, lol. The shadow knows. Anyway, you did great and clearly are talented with such things! Keep up the good work and before too long opensource will finally take over the world!
I am a professional DevOps Engineer with a demonstrated history of working in the internet industry. I am an avid Linux lover and supporter of the open-source movement philosophy.
This is awesome! I love reading different people's approaches to teaching something to a beginner. I like that you took the time to explain what a shell is and why it's useful, because I didn't get that when someone showed me a shell for the first time and I wish I would have.
A couple gotchas to add for newbies:
my_var="Soup"is right, butmy_var = "Soup"will cause errors. The bash shell uses spaces to separate commands from their arguments and split strings into lists, so doing it the second way will make it think you're trying to run themy_varcommand with first argument "=" and second argument "Soup".Anyways, great post! Thanks again :)
Thanks for the feedback! Good point about the variable names, this article is a pretty broad overview so its no surprise I missed a few details like that. But they, I can always write a few follow-up pieces too.
I agree about it being good to explain why the Shell matters. I think that's actually the most important detail for me, since in the start when I researched it, there's no shortage of guides about how to use it. But until I really understood the why with the Pragmatic Programmer, I never saw why it mattered so much to stick through the learning process and bring that all back to my career. That's likely the part of the article I'd have wanted the most for my past self haha.
Yep, and I think you definitely did a great job at that!
I'm a Unix nerd, through-and-through. I love the Mac. It's a great Unix system. I've heard it has a GUI too, but I stick with Terminal and bash. GUI is probably just a fad.
GUI is just a fad. I laughed so hard when I read that! good job
My fav -
cdl() { cd "$@" && ls ; }It took me a very long time before I started using that, but 90% of the time I'm going to
lsafter acd. And because I'm silly, I end upls'ing twice pretty often...That's true, I often do the same. May add this to my alias list myself.
"Vim is, at its core, a text-editor. It's built into the Shell"
This isn't true (that Vim is built into the Shell). Vim might be in a directory contained in your PATH variable, but it's not built into the shell. (Note that I don't capitalize "shell", and I don't know why you do, but that's quibbling.)
Super great article, as someone who loved using GUI's I was pretty against learning terminal at first until I saw how powerful and necessary it was to becoming a Web Developer.
I felt the same for the start of my career too. For git source control I kept using SourceTree due to its GUI until I saw I was missing out on so much of its functionality that way.
Worth mentioning that Bash is the default shell of most Linux distributions. Given Linux is the most popular operating system in the world, and that Bash is available on Mac and Windows too, it's definitely worth learning.
About vim, you can add
to
.bash_profileto switch default editor to Nano.Nano maybe is less powerful but much more intuitive for new bash users (to be honest I still use it and don't want invest my time into vim). And another thing that it is almost on all linux distributions as I know so you don't have to switch from nano editor on your local machine to vim on remote instances
Follow on, my fav unmentioned commands are:
Nope, it's really not. Whatever shell you're using, vim is an application in its own right. Same as the shell is an application.
Most of the time, when I'm installing a new OS, vim isn't even installed by default (but various shell's are).
As a desktop OS, I've tried Yellow Dog Linux, DEC Alpha Tru64 UNIX, and Solaris. (By "desktop" I assume you mean it uses KDE or Gnome or somesuch, and is GUI based with a mouse.)
As a terminal-style OS, I've used Microsoft Xenix. (That was before Xenix was spun off into SCO... and we all know how that story ends.)
I've not used OpenBSD nor FreeBSD. But since I'm a Theo de Raadt fanboy, well OpenBSD is more my bag. On a lark, I have used Darwin for about a week, which owes some lineage to FreeBSD.
All that being said, I also have a warm spot in my heart for Amiga. I am sometimes tempted to get the latest Amiga -- currently A-EON's AmigaOne X5000. But then I open my wallet and see the tumbleweeds blow out of it.
It is getting you to your „home“ directory.
A single „cd“ hit by the enter key, does the same as „cd ~“.
Brilliant post Max!
Aww shucks :)
This should be
homeand notroot,/would be the root directory!I've used the shell quite a bit out of necessity, but this high-level overview has done wonders for bringing my existing knowledge together as well as making me want to learn more!
"You use a Mac, since you have a soul and all" - very weird assumption :) but i like the rest
It's not a assumption, he wrote's to his self in the past, so he know's that he uses a Mac since he have a soul ;)
Great!
Nice! Thanks dude!
Very simple and to the point, funny that I've been using a linux shell for 27 years now but I actually took the time to read your article just to see how you did! I guess you drew in my interest somehow, lol. The shadow knows. Anyway, you did great and clearly are talented with such things! Keep up the good work and before too long opensource will finally take over the world!
:)
Karl (linuxkarl615)
Appreciate the way the subject is dealt and made attractive, right from the start.
Kudos..
Amazing, Amazing, Amazing !! thanks so much, it's really the shell introduction i wish i had!
Alas, the software I write has to run on macOS.
Not sure how easy it would be to setup a toolchain on FreeBSD to produce macOS executables. (I'd probably pick OpenBSD over FreeBSD.)
Great post! 🙌
You should check out this Open-Source Introduction to Bash Scripting Ebook on GitHub as well!:
github.com/bobbyiliev/introduction...