5 hours 21 minutes
Hello and welcome to command line Basics. This very where Delenn links shell scripting and how we can use it to our advantage at the command line. I'm Christopher Heller. And this begin.
So we're learning objectives for this video. We're gonna understand the purpose of a shell script. Learn how to write a shells group, and we're going to execute a shells group
Pre assessment. What is the well known file extension for eight Lennox Shell script, is it a dot shell be dot s h c dot script or D dot Shh. Script.
The answer is B dot s h. This is the well known file extension for a Lennox Shell script that dot s h the dot shell that script Dutch shell script. I mean, you can make them all you want, because limits on its own kind of ignores file extensions.
But as far as for the community and four systems, this is a well known extension to help keep track of these files.
So the purpose of shells groups is that they're used to automate processes.
This is figure similar to the four in the wild loops that we learned in the previous video, where it will execute, you know, specific processes for us without us having to do them over and over. And as we learned in the pretty assessment, they usually have the dot S H extension for a shell script extension.
And it's really useful that help provide all of this different functionality that we've already written in for commands to run.
That way, we don't have to type them out individually or keep typing them over and over again. So it's a very useful way to keep track of these commands and to be able to execute them quickly.
So when we have right a shell script, we need to start with, they should bang at the start. That is that hashtag exclamation point.
Now what this does for a shell script is that tells Thea Lennox system, which specific shell interpreter it needs to use in order to run this command.
So if we use the shebang with flesh, been slash bash, that is just using the bash L for linens. And if you're not very familiar with the different types of shells from Lenox at recommend looking world, so you can become exposed to these different shells and find one that works best for you. But as far as Ah, staying at the shell bash is very good.
And it tells you know this interpreter.
Hey, I need you to use this specific interpret. And so if we were running a Python script with uses, shebang and say, Hey, you need Thio access the Python libraries and they will automatically interpret the script with Python instead of with the bash.
And if you're not familiar with programming already, we use just a single hashtag that's used for comments to help comment out different parts of code and will not be executed.
So writing a shell script, we're gonna use very similar functions as the one line four and wild look that we learned previously where we have her shebang at the top
and then we have the same, you know, four eye where we're defining that parameter in this list of numbers, I want you to echo I.
It's important. Thio. Keep in mind that we have this different type of tabbing for the shell, and it's a lot easier to read into trouble. Shoot if we need to do that and we have the done as well
so Let's go ahead and give an example of this script.
So if I'm gonna do l s
dash L. A
and I have my echo loop, it does show.
So let's go Nano
echo looped a shell to see what it looks like And I have my shebang here have our four loop and the done
So let's exit and we're gonna run it just like any other program were used that don't forward slash
Let me spell it correctly Echo loop that s H and run and it goes ahead Spits out exactly what we told it to one through 10 Echoed So this is a very useful way to be able to write and execute the shell script.
And so, as as we learn, we need to do the dot ford slash and then the name of the file in order to execute it. And just like any other executed will file, we may need to change the file permissions with the Jamaat command that we learned from three previous video
and the make sure you have that execute permission set so we may need to do to Moloch plus X and then the name of the file in order to execute it.
So it is very useful. And you need to keep this in mind when you're writing your shell scripts and if you don't have permission to run them, that's most likely because don't have that Execute permission set.
All right. Supposed assessment. You're right. A shell script. But you don't have the permissions to run it. What command do you execute?
Is it a nano?
Be them. See, I have config wor d jamaat.
The answer is the kebab. We're changing the filed mode bits in order to have that execute permission to run our code.
The Nano command is very useful to write the code similar with the vim where we can write our shells gripped but they're not used to execute the program or configure their permissions that executed and the I have config Command is used for networking for interface that working and it's not used to help
execute any scripts.
All right, so in this video we understood the purpose of Shells Group who learned how to write a shell script. And we also learned how to execute a shell script that we wrote And I hope to see you in the next video
SOC Analyst Assessment Level 1
Cydefe's SOC Analyst Assessment, Level 1, Capture-the-Flag (CTF) Assessment
How to Use GDB (BSWJ)
The GNU Debugger (GDB) is one of the most commonly-used debugging tools in the world. ...
Certificate of Completion Offered