Saturday, 21 September 2013

Get started with Bash

Hi How are you ? i Hop you fine :D Anyway let’s concentrate on this topic.In this article we will learn how to use command line in linux. Command line interfaces can be very powerful.The command line is provided by a shell.So,
WHAT IS SHELL ?

In early days of computing, instruction are provided using binary language, which is difficult for all of us, to read and write. So in Os there is special program called Shell. Shell accepts your instruction or commands in English (mostly) and if its a valid command, it is pass to kernel.Shell is a user program or it’s environment provided for user interaction. Shell is an command language interpreter that executes commands read from the standard input device (keyboard) or from a file.
Shell is not part of system kernel, but uses the system kernel to execute programs, create files etc.Several shell available with Linux including
1. BASH(Bourne-Again SHell)
This shell is being developed By Brian Fox and Chet Ramey From Free Software Foundation. And it is most common shell in Linux. It’s Freeware shell.
2. CSH (C SHell)
This shell is being developed by Bill Joy. He is from University of California (For BSD).The C shell’s syntax and usage are very similar to the C programming language.
3. KSH (Korn SHell)
This shell is being developed by David Korn. From AT&T Bell labs.This is very faster then BASH. There are few more.. :) as i know this much :P
This is How shell interact from user to Kernal
WHAT IS TERMINAL?
if you heard about term, gnome-terminal, konsole, kvt, eterm, and many many others are called Terminal emulators or Terminal.A terminal is a program that opens up a window and then runs a shell in that window. It could be compared to the DOS shell in Windows.Now go ahead and browse the programs menu that you normally use for launching programs, and look for apps that seem like a terminal.You can launch as many of them as you want and try all of them. Different terminal emulators have different bells and whistles, but you run the same shell program, bash, in each of them.
Let me show you Gnome-terminal.
YOu can Press ALT F2 and Then Type gnome-terminal (Debian ,Ubuntu)
################################################################
Now Let me show you Konsole in KDE
As i am using Fedora now, YOu can Press ALT F2 and Then type “Konsole”
Let see what are the shell present in our Ubuntu, Fedora, redhat, backtrack. what ever the Linux Distribution.
1
# cat /etc/shells
gives us an overview of known shells on a Linux system.
1
# cat /etc/shells
This how in Fedora
That’s how in ubuntu or Backtrack we using Bash shell as it always there by default in every Linux distribution
If you want to know current shell.Type following command
1
# echo SHELL
Or
1
# PS -P $$
That’s how in ubuntu or Backtrack,WE currently using Bash

This how in Fedora we are currently using Bash
Now Bring you Ears (Kaan) in Front of my Mouth. 
Shhh.. each shell does the same job, but each understand a different command syntax and provides different built-in functions.In MS-DOS, Shell name is COMMAND.COM which is also used for same purpose, but it’s not as powerful as our Linux Shells are! Any of the above shell reads command from user (via Keyboard or Mouse) and tells Linux Os what users want. If we are giving commands from keyboard it is called command line interface ( Usually in-front of $ prompt, This prompt is depend upon your shell and Environment that you set or by your System Administrator, therefore you may get different prompt like i have ;) )
USING THE COMMAND LINE
If you can see this Figure, commands are entered in terminal at shell prompt. “Hacker” is a lists of login name of a current user “bt” is short hostname of the machine “/” indicates the name of the current directory followed by $ prompt :) Which is in Debian (Ubuntu or backtrack )
If you can see this Figure, commands are entered in terminal at shell prompt. “Hacker” is a lists of login name of a current user “Localhost” is short hostname of the machine.the name of the current directory “~” (that is root /root Directory) in sequare bracket followed by $ prompt :) which is in Redhat(centos, Fedora)this is a meaning of this Line .In Linux you need to understand every things :)
Now Bring you Ears (Kaan) in Front of my Mouth 
If the $ is replace by # Then must be you are runing you Os in superuser(root)Other wise it is consider as a normal usersee above on the given pics
Command entered at the shell prompt have three basic parts
1. Command 
2. Options 
3. Arguments
1. Command
Command is the name of the programe to run.It my be followed by one or more options,
2. Options
Options Which adjust the behaviour of the command or what it will do Option generally started with one or two dashes
3. Arguments
Argument which often indicate a target that the command should operate on
Let me Give you an example
In the above Picture Backtrack i have used
1
#ls -ld /home/
here ls is a command
l is for long listing formate which is an option
d is directory as i have mention /home/ directory which is an option
/home/ is here an argument
similarly in fedora
The above Picture Fedora i have used
here ls is a command
l is for long listing formate which is an option
d is directory as i have mention Desktop/ directory which is an option
Desktop/ is here an argument
One thing More Multiple commands can be seprated by ” ;

No comments:

Post a Comment