linux bash script example

Linux Bash Script Beginner Tutorial : Change MAC address – 2016

What is a Bash Script?

linux bash script example

In computer programming, a script is a program or sequence of instructions that is interpreted or carried out by another program rather than by the computer processor (as a compiled program is). — searchenterpriselinux.techtarget.com

So basically, a bash script is a file in Linux that can be used to automate a list of commands that you normally execute in a specific order. In a bash script, bash is the scripting language we are using. Bash is short for Bourne Again Shell and comes pre-installed on most Linux machines. A bash script can be written in any text editor, and usually saved with a file extension of .sh, however the .sh file extension is optional.

We can use a Bash script to simplify repetitive tasks. For example, to change the WiFi card’s MAC address using the “macchanger” utility (built into Kali Linux) we run the following commands:

ifconfig wlan0 down
macchanger --mac 00:11:22:33:44:55 wlan0
ifconfig wlan0 up
dhclient wlan0

Now, it’s okay if you want to keep typing the above commands every time you want to change your mac address, however it can get annoying after a while. Wouldn’t it be easier if we could just run a simple script that could automatically run the commands shown above? The answer is, Yes. In the following article, I am going to teach you how to create a very basic Linux Bash script, without creating the infamous “hello world” script. 🙂

Continue reading

WPA_Supplicant config for WPA encryption Backtrack 5

Why use WPA_Supplicant Daemon?

Wpa_supplicant config

So after finding an old Backtrack 5 R3 persistent USB drive I had created years ago, I booted it up to browse the content I had on it. Last time I used it, I was connected to a WEP encrypted network, but as we all know those offer weak protection and are slightly outdated for today. The tools and techniques to break WEP encryption have been around for a while and therefore WEP is rarely used these days. That being said, WPA encryption isn’t flawless, but a better alternative. I’m not going to discuss how to crack those here. Anyway, I figured I would share with you how to connect to a WPA encrypted network in Linux using the terminal and WPA_Supplicant daemon.

If you’re still using Backtrack 5 R3, I recommend upgrading to Kali Linux by creating a persistent USB.

Normally, we use iwconfig to configure wireless networks. However, iwconfig does not support WPA/WPA2 encryption. We have to use the “WPA_Supplicant Daemon” to connect to a WPA encrypted network.

Wpa_supplicant comes pre-installed in most Linux distros (including Backtrack 5 R3, Kali Linux and Ubuntu). Since Backtrack 5 R3 is outdated, it is configured to make connecting to WEP encrypted networks easily,

Continue reading