Logo

dev-resources.site

for different kinds of informations.

Thrash with BASH

Published at
2/10/2024
Categories
bash
scripting
linux
kali
Author
odoth4kz
Categories
4 categories in total
bash
open
scripting
open
linux
open
kali
open
Author
8 person written this
odoth4kz
open
Thrash with BASH

Greetings all,

If you read my last post you would understand the focus behind cybesec right now. Writing notes this AM, looking at the glitching phone screen, it's time to make things happen in a major way. Booted up Youtube via the Raspberry Pi 4 and began looking for project ideas. Before doing so, I sat and thought for a moment. Let's work on BASH deeply! Grabbing my coffee mug I start to search for how to automate the daily tasks. This is simply what the scripting language made for. First things first, let's begin with the basics. What is BASH?

BASH (BOURNE AGAIN SHELL) scripting saves the user time so certain commands aren't written repeatedly. Bourne shell (sh) is used as the format for bash files but not required at end. The script is a series of commands that make of the file. When executed, they are read line by line so it's easy syntax to write and read in my opinion.

To start a script, you first would need a shebang. This combo consist of bash # **and **bang ! followed by the path of the bash shell. There's much more behind the shebang, but that will be added in the resources below.

shebang example:

`#! /bin/bash

To find the path of the bash shell, use the following command:

which bash

output for kali is :

/usr/bin/bash

so the ending of result would be the following when using a shebang in Kali linux:

`#! /usr/bin/bash

*Nano * is an incredible text editor that is built-in most linux distributions. The Nano text editor allows users to create BASH scripts.

Installation of Nano
sudo apt install nano

Open Nano
nano
nano <filename> (this option creates the name of script)

Example:
nano myscript.sh

Navigation of the GUI is quite simple. The commands I use the most thus far are Save, Copy, Paste and Exit. There are many more commands that are great to use, but like I tell all please do your research. Don't just read my blog, but check out the resources I add below. Respectfully.

Save File

Ctrl + s

Exit Nano

Ctrl + x

Copy

Ctrl + Shift + C

Paste

Ctrl + Shift + P

Now that you have the basic commands, let's create a simple bash script that will say "LINUX IS POWERFUL!" using Nano. No worries, I will walk you through it so you don't have to sweat. Are you set. Let's get to it.

Steps:

nano myscript.sh

#! /usr/bin/bash

echo 'Linux is Powerful!

Ctrl + s * add file name "myscript.sh"

Ctrl + x

Congrats! You have completed your first BASH script. Now you are asking the question of how you run the script eh!? Hmm... I guess I'll provide that for you. When executing the script you first need to make it executable. To make it executable we use the change **file permissions **of the script.

chmod +x myscript.sh

Then to to execute the script use:

bash myscript.sh

Ha! Now your good to go with the first script fully built and ran successfully! Now, do you want to make it a bit more interesting?! Let's take it up a notch and work with variables. Here's an example of a simple variable being created and used below.

name = ODOT
echo $name

Now I suggest you to try! See if you can create simple variable to add to your script. BASH has so much more to offer allowing users to automate workflows endless. As always I provide just a insight into the world then it's up to the reader to decide if they want to learn more. Resources are always provided below to help you on your journey. Well until next blog. Peace!

*Resources *

What is Nano Text Editor?

BASH for Beginners

What is a shebang?

File Permissions

OLOG Repo

kali Article's
30 articles in total
Favicon
[Boost]
Favicon
Worms, Bots, and Botnets: How Hackers Take Over the Internet!
Favicon
Create a Powerful Hacking Lab: Install Kali Linux in Minutes!
Favicon
Kali Linux for Ethical Hacking: The Ultimate Toolkit for Cybersecurity Professionals
Favicon
Kali Linux For Beginner
Favicon
Install Kali NetHunter On Your Android Device
Favicon
Not bad but not good enough
Favicon
Beyond Basics: Traversing Kali Linux Tools
Favicon
Encrypt/Decrypt File Using Openssl
Favicon
Thrash with BASH
Favicon
Download Bluetooth in Kali Linux
Favicon
Realizando ataques de força bruta em containers docker usando hydra
Favicon
Deauthentication Attack using Kali Linux
Favicon
HiDPI In Kali Linux Through RDP | Hyper-V
Favicon
Kali Linux on Android Devices
Favicon
Mengatasi Install Kali Linux Berhenti di Detect Network Hardware
Favicon
Grub-customizer won't change your GRUB theme in Kali Linux? Try this
Favicon
Deploying your Kali-linux templates with Cloud-init, under Proxmox VE
Favicon
Linux top 15 shell commend.
Favicon
3 Easy Commands to Install Postman in Kali Linux
Favicon
Installing Snort on Kali Linux
Favicon
KALI LINUX: Common Commands that you should know : PART 2
Favicon
Kali vs Ubuntu
Favicon
Fast nmap scanning
Favicon
File upload bypass using MIME-type
Favicon
How to get Kali tools and Snap on a Chromebook
Favicon
Installing Libre Office in Kali Linux
Favicon
Adaptador de red wireless BCM4360 en Kali Linux
Favicon
Kali VPN Tweaks for TryHackMe
Favicon
Top 6 Ethical Hacking Tools

Featured ones: