Shell Scripting - Introduction & Shebang

HackerSploit · Beginner ·📰 AI News & Updates ·7y ago

Key Takeaways

Introduction to shell scripting and the Shebang line in Unix shell scripting, presented by HackerSploit

Full Transcript

[Music] hey guys hackersploit here back again with another video and welcome to the shell scripting course now you might be a little bit confused as to why i'm making this course but this was probably the highest requested series on the channel and uh you know after giving it a lot of consideration i think it is is extremely important for me to cover this so uh without further ado let's get started so for those of you who are new to the whole idea of bash scripts you might be wondering what they are and what they do well simply uh simply put bash scripts allow you to execute commands from a file now the thing that many people don't understand here or the thing that people don't uh they don't really get to understand is the fact that the interpreter is the shell that's the brilliant thing about this now when when i say that the interpreter is the shell you pretty much get to understand that with a bash or a with a bash script you have unlimited functionality when it comes down to the unix tool set all right so what do i mean by this if you're performing uh python scripting the whole idea of modules come comes into play but if i'm using batch scripting to create a script for example it is much more convenient and will work pretty pretty much all the time without me having to install dependencies or additional or additional extensions or modules for that matter okay so that being said i am going to be covering python scripting i have covered it before but i'll be covering that in depth uh and i want to really explain you know functions because i haven't touched upon that for uh you know in a while but that being said why uh why is bash scripting preferred over python scripting of course that is a very uh that's a very opinionated statement and i do agree but if you ask any systems administrator they will go with bash scripting like 100 of the time over python because when you compare them python is less reliable when it comes down to passion again i said that because it's going to use the shell as the interpreter the shell is built in with unix and it will it will enable you to utilize the entire unix tool set that means you can control sockets with just by typing in each command each command on each line you know so it's really even very intuitive for a person to understand it now uh what is batch scripting very good at number one file management all right with bad scripting and as i've mentioned systems administrators they can vouch for this that bash scripting allows you to copy files update files backup files almost on an fully automated basis and i've seen many of the systems administrators as well as when i was one you know creating bash scripts to do anything from all the all the way from querying a data in an excel worksheet uh to uh to compiling data uh getting figures producing mass amounts of data which i know again many of you will argue python is the king of data uh you know in data science but uh bash is pretty good to be honest the only the only area where it falls off a little bit is when it comes down to huge calculations you know calculations that involve statistics and the merging of all other types of data so that's where it kind of lags off and you can understand why it's really focused on a on a system it's focused more on controlling a system so it's really good for running for file management running scripts and programs and for automating tasks now i'm going to be showing you how to write a few cool scripts that allow you to you know whether you want to call them pen testing scripts or whatever uh and the reason again i was forced to make this course is because uh i was having a discussion with one of the subscribers on facebook and they they didn't quite understand how exactly we were like when performing privilege escalation and you're trying to use python to spawn a shell uh or a or a bash instance uh how how that was happening and again this came from uh this question was raised because they did not understand a thing about bash and how the shell how powerful the terminal as we call it is you know in regards to controlling every aspect of the system now that being said what we will be looking at in this series will range from you know from very basic things to an advanced uh type of to an advanced type of videos we'll be focusing on creating onscript and that's how i want to keep it so we'll be focusing on constants input output uh conditional statements like if else loops variables functions etc and then also file management we'll look at all of that so i'll be showing you how to create a lot of awesome scripts even for those of you who who use raspberry pi's uh you know for automation and for various different things i'll show you how to write even cooler scripts for that as well all right so my environment is pretty simple and you can use this on any linux slash unix operating system i really don't know what you want to call it but many have different opinions about it and the editor i'll be using is going to be sublime text now of course you can use whatever you want i just like sublime text for bash uh or for bash scripting is b because of it's it's just really really simple for me and you can use any but for me i just prefer using sublime text all right so i'm gonna be using sublime text and let's get started so before we create our first shell script or uh or our bash script uh our bash script uh it's very important to understand uh how data is uh is handled and how and when i talk about the shell being the uh being the interpreter what i mean by this now of course you might be saying well python also has an interpreter that is based on a command line well that's slightly does its own interpreter which as you see causes problems especially for those of you who really are moving back and forth from python 3 to python python 2. all right so let's say i wanted to just you know create a simple script that will display the word hello you know so to do that as you know i type in echo if you didn't know echo essentially displays the text it's essentially echoing the text back to you all right so i type in echo and i just type in hello now this is uh primarily a shell script what do i mean by this it's simply a command that the shell will interpret and i type in enter you can see that it is interpreted and it has understood what we are trying to say now of course i can i can complicate it as much as i want i can say uh hello uh we can just you can write whatever you want but the whole idea is is that the shell as probably not a lot of you understand can do a lot of things now when i talk about scripting this essentially is the uh it essentially allows you to execute a lot of these commands from a file okay from a file that's the whole idea of a script remember from a file but when talk about the shell the shell can run commands that you want it to the problem is many people have forgotten how powerful it is so let's create our first uh shell script all right so to do that i'm just going to open up sublime text here and uh in i'm i'm just going to be covering how to create it in the next video we'll get started with variables because i really do want to cover this so let me just zoom in all right so when we talk about creating a shell script you know that the extension is a shell extension so let me just create a new file and i will save it to my desktop uh sorry let me just save this to my desktop right here desktop and i'll call this uh simple dot sh all right dot sh is the extent extension we use for shell scripts so dot s dot sh and i'm gonna hit save and as you can see it's right on the desktop now all right but remember it has nothing in it so even if we are to execute it uh nothing will come of it so what's the first thing we need to do the first thing we need to do is we need to declare what interpreter we're going to be using this is where a lot of people don't understand they have seen something like this all right so they've seen um usually what happens is they they they come across something like this and i know you guys are going to be like well what exactly do you mean well uh they come across something like this all right and i i failed to to explain it uh in python but let me explain it now when i type this in this is called the shabang i'll get i know it sounds uh quite funny but i'll get to to what this is in a second this is called the shebang primarily because of um of the uh the different meanings of uh for example this is a sharp and this uh is used for the music uh and the uh the bang annotation in music so from that they essentially determined to call it shebang all right so anything after a shabang in a script uh will essentially be used as the interpreter okay now in this case the bash is going to be the interpreter remember it can also be python python can also be used as the interpreter as we saw in the python scripting uh when we were creating our reverse shells and our clients etc in this case it can be it can be either the bash it can be the bash it can be the shell as you have probably noticed when performing privilege escalation might be saying hey man what's the difference the shell is different from the bash the bastion is considered to be a terminal instance which gives you a much more streamlined um streamlined what's the correct word for this experience when it comes down to using the linux or unix operating system the shell is simply the shell the interpreter of commands and as you know this does not give you full access in terms of functionality you then have the other interpreters that are not really used that much nowadays which are the csh and the zsh or the ksh which i'm not going to go into but they have very very diff they vary in terms of their functionality so we are going to be using the bash all right so once we have said this what this means is i want you to use this as our interpreter fair enough all right so now we can run our simple script here a simple script is going to simply display uh the words hello world now of course i'm going to use the parentheses here just to make sure that everything i type within them is printed out so i can say hello uh oops sorry my bad hello world uh and uh this is the first uh shell script all right there we are fantastic so uh now if we save this uh just give me a second let's save this and uh if we can open up our terminal here uh huh and uh what's my current working directory all right so cd uh sorry about that guys uh cd root and and let's see what's in there all right so now as you probably would have known from my other videos executing a script is quite simple all we do is we select the interpreter when we're executing a python script we can use python and some of you have noticed when you use python it works most of the time and have you realized something that for example if it was a python script a very poorly designed python script and we try and execute it like this this essentially means we are specifying the we're essentially saying use the specified interpreter and in in that script the developer has not specified the interpreter what happens is if we try and use this to execute a python script for example it will not run you'll get an invalid argument specification what that means is that the developer has not specified what to use as the interpreter and again you can understand why that is considered bad practice always specify the interpreter so that people can launch the scripts without specifying the interpreter intentionally remember all right so if we try and uh if we try and run this simple script um for some reason you'll see that um wait give me a second guys uh yeah you'll see that we cannot we cannot uh we can also we we cannot really use the uh the tab auto completion and that's because the permissions in regards to the script oops my keyboard today is really letting me down the permissions in regard in regards to the script clearly determine here that we we can only read the file but we cannot execute so as i've mentioned before we can use the uh we can change the permissions of the executable file now i'll be explaining permissions and why they're important with running uh the uh the scripts because you might want to have a script run by a certain user we'll get to that but for now let me just make sure that we can execute it and we use the chmod plus x and we spent we specified the script and we hit enter and now if you list it you can see that it's going to be highlighted in a green you all right so i'm going to run the script so simple and if i hit enter you can see it's going to display what we wanted it to display now of course this is very simple but what i want to explain is the syntax right from the beginning because i've seen a lot of developers even people you know systems admins that are working for huge companies really don't understand what what the what interpreter they're using and you know they usually find out that their scripts are not executed by certain users file permissions etc it's really a big it's a big task to understand uh you know shell scripting but once you do it really is a powerful a really really powerful tool or language for that matter to know okay so now you might be saying well what if what if alexis what if i wanted to revert the permissions that i've given this script well to do that we run the chmod but instead of the the the plus x we use the minus x and then we say simple dot sh and now if you list the files in here you can see that it is back to having uh the permissions as read only fantastic so now you know how to create your first shell script and you know about file permissions and you know about interpreters and the different interpreters you can use now remember this is global knowledge when it comes down to uh to selecting your interpreter this is quite universal and is extremely important when creating scripts now of course this is an extremely simple script but in the following videos we'll get started with the real real nitty gritty of shell scripting that being said that's gonna be it for this video uh if you have any questions or suggestions let me know in the comments section on my social networks on my website and i'll be sure to leave your reply and i'll be seeing you in the next video [Music] peace

Original Description

Hey guys! HackerSploit here back again with another video, in this series we will be looking at how to create shell scripts. A shell script is a computer program designed to be run by the Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages ⭐Help Support HackerSploit by using the following links: 🔗 NordVPN: https://nordvpn.org/hacker Use the link above or the code below for 77% Off your order Promo Code: hacker Patreon: http://patreon.com/hackersploit I Hope you enjoy/enjoyed the video. If you have any questions or suggestions feel free to ask them in the comments section or on my social networks. 🔗 HackerSploit Website: https://hsploit.com/ 🔗 HackerSploit Android App: https://play.google.com/store/apps/details?id=com.hsploitnews.hsploit&hl=en 🔹 Support The Channel NordVPN Affiliate Link: https://nordvpn.org/hacker Patreon: http://patreon.com/hackersploit 🔹 Get Our Courses Get a special discount on our courses: The Complete Deep Web Course 2018: https://www.udemy.com/the-complete-deep-web-course-2017/?couponCode=DWCBP2017 🔹 SOCIAL NETWORKS - Connect With Us! ------------------------------- Facebook: https://www.facebook.com/HackerSploit/ Instagram: https://www.instagram.com/alexi_ahmed/ Twitter: https://twitter.com/HackerSploit Patreon: http://patreon.com/hackersploit -------------------------------- Thanks for watching! Благодаря за гледането Kiitos katsomisesta 感谢您观看 Merci d'avoir regardé Grazie per la visione Gracias por ver شكرا للمشاهدة دیکھنے کے لیے شکریہ देखने के लिए धन्यवाद
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from HackerSploit · HackerSploit · 0 of 60

← Previous Next →
1 How To Install Kali Linux 2.0 On Virtual Box
How To Install Kali Linux 2.0 On Virtual Box
HackerSploit
2 100 Subscriber Q&A! - How I Learned Ethical Hacking
100 Subscriber Q&A! - How I Learned Ethical Hacking
HackerSploit
3 BlackArch Linux Review - Better Than Kali Linux?
BlackArch Linux Review - Better Than Kali Linux?
HackerSploit
4 How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
HackerSploit
5 Wireshark Tutorial for Beginners - Installation
Wireshark Tutorial for Beginners - Installation
HackerSploit
6 Wireshark Tutorial for Beginners - Overview of the environment
Wireshark Tutorial for Beginners - Overview of the environment
HackerSploit
7 Wireshark Tutorial for Beginners - Capture options
Wireshark Tutorial for Beginners - Capture options
HackerSploit
8 Wireshark Tutorial for Beginners - Filters
Wireshark Tutorial for Beginners - Filters
HackerSploit
9 Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
HackerSploit
10 Complete Ethical Hacking Course #2 - Installing Kali Linux
Complete Ethical Hacking Course #2 - Installing Kali Linux
HackerSploit
11 Parrot OS 3.5 Review | The Best Kali Linux Alternative
Parrot OS 3.5 Review | The Best Kali Linux Alternative
HackerSploit
12 Nmap Tutorial For Beginners - 1 - What is Nmap?
Nmap Tutorial For Beginners - 1 - What is Nmap?
HackerSploit
13 Katoolin | How To Install Pentesting Tools On Any Linux Distro
Katoolin | How To Install Pentesting Tools On Any Linux Distro
HackerSploit
14 Nmap Tutorial For Beginners - 2 - Advanced Scanning
Nmap Tutorial For Beginners - 2 - Advanced Scanning
HackerSploit
15 Nmap Tutorial For Beginners - 3 - Aggressive Scanning
Nmap Tutorial For Beginners - 3 - Aggressive Scanning
HackerSploit
16 Zenmap Tutorial For Beginners
Zenmap Tutorial For Beginners
HackerSploit
17 How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
HackerSploit
18 How To Setup Proxychains In Kali Linux - #2 - Change Your IP
How To Setup Proxychains In Kali Linux - #2 - Change Your IP
HackerSploit
19 How To Change Mac Address In Kali Linux | Macchanger
How To Change Mac Address In Kali Linux | Macchanger
HackerSploit
20 How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
HackerSploit
21 Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
HackerSploit
22 VPN And DNS For Beginners | Kali Linux
VPN And DNS For Beginners | Kali Linux
HackerSploit
23 Tails OS Installation And Review - Access The Deep Web/Dark Net
Tails OS Installation And Review - Access The Deep Web/Dark Net
HackerSploit
24 Steganography Tutorial - Hide Messages In Images
Steganography Tutorial - Hide Messages In Images
HackerSploit
25 The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
HackerSploit
26 Best Linux Distributions For Penetration Testing
Best Linux Distributions For Penetration Testing
HackerSploit
27 Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
HackerSploit
28 Gaining Access - Web Server Hacking - Metasploitable - #1
Gaining Access - Web Server Hacking - Metasploitable - #1
HackerSploit
29 Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
HackerSploit
30 How To Install Kali Linux On VMware  - Complete Guide 2018
How To Install Kali Linux On VMware - Complete Guide 2018
HackerSploit
31 Q&A #1 - Best Cyber-security Certifications?
Q&A #1 - Best Cyber-security Certifications?
HackerSploit
32 Terminator - Kali Linux - Multiple Terminals
Terminator - Kali Linux - Multiple Terminals
HackerSploit
33 Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
HackerSploit
34 Q&A #2 - Mr Robot?
Q&A #2 - Mr Robot?
HackerSploit
35 Metasploit Community Web GUI  - Installation And Overview
Metasploit Community Web GUI - Installation And Overview
HackerSploit
36 Linux Expl0rer - Forensics Toolbox - Installation & Configuration
Linux Expl0rer - Forensics Toolbox - Installation & Configuration
HackerSploit
37 QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
HackerSploit
38 Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
HackerSploit
39 Metasploit For Beginners - #2 - Understanding Metasploit Modules
Metasploit For Beginners - #2 - Understanding Metasploit Modules
HackerSploit
40 Kali Linux Quick Tips - #1 - Adding a non-root user
Kali Linux Quick Tips - #1 - Adding a non-root user
HackerSploit
41 Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
HackerSploit
42 Spectre Meltdown Vulnerability  - How To Check Your System
Spectre Meltdown Vulnerability - How To Check Your System
HackerSploit
43 Metasploit For Beginners - #4 - Basic Exploitation
Metasploit For Beginners - #4 - Basic Exploitation
HackerSploit
44 ARP Spoofing With arpspoof - MITM
ARP Spoofing With arpspoof - MITM
HackerSploit
45 WordPress Vulnerability Scanning With WPScan
WordPress Vulnerability Scanning With WPScan
HackerSploit
46 Generating A PHP Backdoor with weevely
Generating A PHP Backdoor with weevely
HackerSploit
47 Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
HackerSploit
48 How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
HackerSploit
49 Stacer - System Optimizer And Monitoring Tool For Linux
Stacer - System Optimizer And Monitoring Tool For Linux
HackerSploit
50 Kali Linux 2018.1 - Kernel Updates & Patches
Kali Linux 2018.1 - Kernel Updates & Patches
HackerSploit
51 MITM With Ettercap - ARP Poisoning
MITM With Ettercap - ARP Poisoning
HackerSploit
52 Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
HackerSploit
53 How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
HackerSploit
54 Channel Updates - How To Post Questions & Video Suggestions
Channel Updates - How To Post Questions & Video Suggestions
HackerSploit
55 Web App Penetration Testing - #1 - Setting Up Burp Suite
Web App Penetration Testing - #1 - Setting Up Burp Suite
HackerSploit
56 Web App Penetration Testing - #2 - Spidering & DVWA
Web App Penetration Testing - #2 - Spidering & DVWA
HackerSploit
57 Cl0neMast3r - GitHub Repository Cloning Tool
Cl0neMast3r - GitHub Repository Cloning Tool
HackerSploit
58 Kali Linux On Windows 10 Official - WSL - Installation & Configuration
Kali Linux On Windows 10 Official - WSL - Installation & Configuration
HackerSploit
59 DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
HackerSploit
60 Web App Penetration Testing - #3 - Brute Force With Burp Suite
Web App Penetration Testing - #3 - Brute Force With Burp Suite
HackerSploit

This video introduces the basics of shell scripting, including the Shebang line, and provides a foundation for creating shell scripts in Unix. The video is presented by HackerSploit and covers the fundamentals of shell scripting and scripting languages.

Key Takeaways
  1. Understand the basics of shell scripting
  2. Learn about the Shebang line
  3. Create a basic shell script
  4. Use a command-line interpreter
💡 The Shebang line is a crucial component of shell scripts, specifying the interpreter to use when running the script.

Related AI Lessons

The AI Moat Paradox: The Better Models Become, the Less Models Matter
The AI moat paradox suggests that as AI models improve, their importance may decrease, and understanding this concept is crucial for AI professionals and businesses.
Medium · AI
170,927 AI Papers Reveal the Biggest Research Shifts of the First Half of 2026
Discover the biggest AI research shifts of 2026 based on 170,927 papers, and learn how to apply these trends to your work
Medium · Machine Learning
170,927 AI Papers Reveal the Biggest Research Shifts of the First Half of 2026
Discover the major research shifts in AI from 170,927 papers published in the first half of 2026, and learn how to analyze trends in AI research
Medium · Data Science
[PoV] When Everyone Is Smart, No One Is
In a world where AI makes everyone smart, the value of intelligence decreases, and new challenges arise
Medium · AI
Up next
‘ENOUGH IS ENOUGH’: Lebanon is STANDING UP to Iran, expert says
Fox Business
Watch →