Shell Scripting Tutorial – 1

Hello,

I am Aaditya Purani. Today i would be Presenting Shell Scripting Tutorial -1 The basic one 🙂

A shell script is a text file that contains a sequence of commands for a UNIX-based operating system. It’s called a shell script because it combines into a “script” in a single file a sequence of commands that would otherwise have to be presented to the system from a keyboard one at a time.

bash

So, first of all if you need to cook up a shell code , you need to start with

#!/bin/sh

It means script will always run with bash. /bin/sh is an executable representing the system shell . Now, getting this overview, you might be knowing about Printing text in PHP. So let’s print Hello World .First open any text editor and type the code

Code:

#!/bin/sh

echo “Hello World!”;

Done. Now, save it as file . Now, to execute it (if you are root user) then type bash file which will print Hello world in Terminal. Now, Shell Scripting is all about commands . Let me list all files with their permission.

Code:

#!/bin/sh

echo “Lets see files”;

ls -lha

ssx

So, here is what it looks, Now if you are not as root user, then you need to give chmod +x file and then run the file. It will give executable permission. Now, let’s go more and print the version of your Linux Distribution. I use Kali Linux

Code:

#!/bin/sh

echo “Lets see files”;

ls -lha

echo “Show me version”

cat /etc/issue

xxxThat’s the output. Now you can watch a video of mine 🙂 Please don’t copy, if you want to put on your blog . Provide me credits.

https://www.youtube.com/watch?v=7Fsn21qEq6o

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s