- Podcasts
- CyberSecurity Summary
- Linux Command Line and Shell Scripting Bible
Linux Command Line and Shell Scripting Bible
CyberSecurity Summary
- December 28, 2024
- 28 min
About this episodeThe Book provide a comprehensive guide to Linux command-line tools and shell scripting. They cover fundamental concepts like navigating…
You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary
Get the Book now from Amazon:
https://www.amazon.com/Linux-Command-Shell-Scripting-Bible/dp/1119700914?&linkCode=ll1&tag=cvthunderx-20&linkId=08da820d12aed79f5fa1b6b7174ce5f7&language=en_US&ref_=as_li_ss_tl
Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Linux Command Line and Shell Scripting Bible
Well, I would say it's important to know the difference because it affects how you interact with the system. So when you think about virtual consoles, you want to think about it's like a direct connection to your system's heart. It runs right on the system memory. Oh, so it gives you that old school no frills command line experience. Now, terminal emulators are like command line windows within your graphical desktop environment. Okay, they're going to give you more flexibility and features, but they do have a little bit of a performance trade off.
Yeah, I guess that makes sense. It has to run inside of the graphical environment. Okay, So choosing between those two is like choosing if you're going to be a survivalist or if you want like the modern conveniences of the graphical environment. But in both cases you're still using that command line. So now that we're in the command line, how do you find your way around? It's not like Windows with folders and icons and all of that.
Yeah. So you've got a master tab completion. Okay, that's your first step towards being a command line ninja. Right, just start typing a command or file name, hit the tab key, and then the shell will just magically complete it for you. It's going to give you suggestions. It is a real time saver, right.
They start with a period, and they're normally invisible, right okay, and they often contain some pretty important configuration settings or system data. So if you ever need to delve into that hidden world, the LSA command is your go to. It's like putting on X ray vision for the file system.
Yes, So that's where we've got output redirection. Okay, this is one of those aha moments. Once you learn how to use it. The symbol is your friend here. Okay, you can readirect the output of a command to a file, so instead of seeing it on the screen, you can capture it, put it in a file, and use it later for analysis or reference. Oh that's so useful. Yeah, instead of it just flying by on the screen.
I like having options. You got it now. I also see nested if statements. Yes, are those like nsted if statements? Those rush yes exactly, like those Russian nesting dolls with one if statement inside of another. Okay, So that allows you to create more complex decision making logic. You know, it's like creating a multi level decision tree.
So the wile loop is like this persistent little engine. Okay, It keeps running as long as a specific condition remains true. Okay, So it's perfect for situations where you don't know in advance how many times you need to repeat those commands. So imagine you're monitoring a system log file okay, and you're waiting for a specific error message to appear. Yeah, a while loop can keep checking that file, oh okay until that message pops out.
It's like, nope, not that one, move on to the next exactly exactly. Okay. These loop control commands are really cool. So I've got conditional statements for decision making, we've got loops for repeating actions. What else can we do to make our scripts a little more interactive and powerful.
Yeah, So the book outlines three ways to handle those options, okay, so you can process them directly as parameters. You can use if statements to check for specific options, or the most elegant approach is to use the get tops command get tops get tops. You know that's your built in option parsing wizard.
So local is your friend when it comes to keeping variables organized within those functions. It lets you declare variables that are only visible inside that function. Okay, prevents naming conflicts with variables in your main scriptstcha, you know, other functions. It's good practice to use local variables within functions to keep things nice and tidy.
Yeah. So SAID stands for stream editor, okay, and it's all about working on streams of text, processing data line by line. So imagine you have a massive log file or a databased stump. Instead of loading the whole thing into memory, right, said, lets you process it efficiently one line at a time.
Sure. Let's say you have a file with a list of names. Okay, each one's on a separate line, like John Smith, Jane Do, and so on, and you want to just extract the last names from those lines. Okay, Well, with said and a simple regular expression, you can do that instantly. Oh wow, The regular expression would target the space between the first and last name. Oky, Intel said to only output the part of the line after the space.
Gawk is another powerhouse, but it's more like a programming language specifically designed for data manipulation, so it goes beyond that simple text manipulation. Allows you to perform calculations, use variables, even structure your code with conditional statements and loops, just like you would in a traditional programming language.
Right, yes, yes, So each shell has its own philosophy, features and little quirks. Okay, So this book talks about the dash shell. It's a lightweight alternative to Bash, often the default shell in Debian based distributions like a Buntu because it's so efficient, but it might not have all those advanced features.
