Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-20-2015, 02:13 AM   #1
LQ Newbie
Registered: Nov 2015
Posts: 1

Rep: Reputation: Disabled
Difference b/w sh, ksh and bash and it's uses

Dear Linux Genius,

I'm new to Shell scripting and i want to know the difference b/w sh, ksh and bash shell scripting and also want to know when to use these shell scripting techniques.
Can you please suggest me go further. If possible pls share one example it will help me for better understanding.

Thanks in Advance.
Old 11-20-2015, 02:29 AM   #2
Senior Member
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,492

Rep: Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921Reputation: 921
sh is the original UNIX shell. Also known as Bourne shell after its original designer. See also
ksh is the Korn shell, also named after its original designer. It adds numerous features to sh, in particular with regards to interactive use. See
There is also a POSIX shell which attempts to standardize shell behaviour.
Bash ("bourne-again shell") is the standard Linux shell. It's POSIX-compliant but has many additional features. See

Wikipedia also contains a lot of info about the shell.

For shell scripts, use sh or POSIX shell if you need maximum compatibility, and bash if not. Bash has many features that make it easier to write and read scripts. For example, this original Bourne shell code:
if [ expr "$a" + "$b" -gt 13 ]
then ....
can be written as follows in bash:
if (( a+b>13 ))
then ....
On many (most? all?) distros /bin/sh is a symbolic link to /bin/bash; you need to check if the Bourne shell exists at all.
Just checked - the standard Centos 7 repositories don't appear to have the Bourne or Posix shell. ksh is available though.

Last edited by berndbausch; 11-20-2015 at 02:30 AM.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats the difference between ksh and bash? dev_d Linux - Newbie 11 02-26-2010 04:17 PM
Bash vs ksh Nickbrandson Linux - Newbie 7 04-23-2008 06:40 PM
the difference ksh wanghao Linux - Server 2 03-19-2008 06:18 AM
How to switch from BASH to KSH? tejpatil Linux - Software 13 06-14-2007 02:03 PM
bash or ksh noir911 *BSD 5 05-10-2007 11:08 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:53 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration