Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Difference between sh and bash
Next article icon

Difference between sh and bash

Last Updated : 21 Feb, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

bash and sh are two different shells of the Unix operating system. bash is sh, but with more features and better syntax. Bash is “Bourne Again SHell”, and is an improvement of the sh (original Bourne shell). Shell scripting is scripting in any shell, whereas Bash scripting is scripting specifically for Bash. sh is a shell command-line interpreter of Unix/Unix-like operating systems. sh provides some built-in commands. bash is a superset of sh. Shell is a command-line interface to run commands and shell scripts. Shells come in a variety of flavors, much as operating systems come in a variety of flavors. So, Shell is an interface between the user and the operating system, which helps the user to interact with the device.

sh:

#!/bin/sh

bash:

#!/bin/bash

Note:

  • Shell is an interface between the user and the operating system.
  • sh implements the shell interface.
  • bash is a superset of sh.

sh:

sh is also called Bourne Shell. sh is a command programming language described by POSIX standard. It is for UNIX or UNIX-like operating systems. It has many implementations. On most operating systems, sh is implemented by programs like dash, kash, and original Bourne Shell. sh is a Predecessor of bash. /bin/sh is an actual link to main implementations. It is a symlink in most POSIX systems.

sh is not a programming language itself. It is just a specification. sh is a detailed description of the syntax and semantics of the language. It doesn’t include an implementation. sh is written as a replacement for earlier UNIX shells. It's most of the syntax is the same as the syntax of the ALGOL68 programming language.

We should use sh if we want our language to be compatible with multiple systems. The sh script will most like run on bash also without modifications as bash is backward compatible with sh. sh is the most portable scripting language that works on most POSIX/Unix/Linux systems. One advantage of sh is that it is guaranteed to exist on everything that purports to Unix system. 

bash:

bash is also a command programming language like sh. Nowadays, bash is a default login shell on most Linux-based operating systems. It is an extended version of the sh system for GNU replacement for the Bourne shell. We can also say bash is a programming language. Here think like python, we can start python in interactive mode and it behaves like a shell but we can also run python program on any IDE.

bash is a superset of sh. This means that bash supports features of sh and provides more functionality than sh. Although most commands do the same thing as sh. bash is not a POSIX compliant shell. It is a dialect of the POSIX shell language. Bash can run in a text window and allows the user to interpret commands to do various tasks. It has the best and most useful features of the Korn and C shells, such as directory manipulation, job control, aliases, and many others.

Like GNU software bash provides other shells, including a version of csh, Bash is the default shell. bash is intended to be a conformant implementation of the IEEE POSIX Shell and Tools portion of the IEEE POSIX specification (IEEE Standard 1003.1). Like other GNU, bash is also quite portable. This works on any Linux/Unix-based system which has bash in the expected location. bash is more functional than sh in terms of programming and interactive use.

Difference between sh and bash : 

bash

sh     

  • Bourne Again SHell
  • SHell
  • Developed by Brain Fox
  • Developed by Stephen R. Bourne
  • Successor of sh
  • Predecessor of bash
  • bash is the default SHELL
  • sh is the not default SHELL
  • #!/bin/bash
  • #!/bin/sh
  • It has more Functionality with up-gradation.
  • It has less functionality.
  • supports job controls.
  • does not support job control.
  • bash is not a valid POSIX shell.
  • sh is a valid POSIX shell.
  • Easy to use
  • not as easy as bash
  • less portable than sh.
  • more portable than bash.
  • Extended version of language
  • Original language
  • Bash scripting is scripting specifically for Bash
  • Shell scripting is scripting in any shell
  • supports command history.
  • does not supports command history.

Next Article
Difference between sh and bash

R

rushi_javiya
Improve
Article Tags :
  • Computer Networks
  • Difference Between

Similar Reads

    Difference Between Python and Bash
    Python and Bash both are both automation engineers' favorite programming language. But sometimes it may become difficult to choose any one of them. So you might be looking for articles telling which language to choose. But the honest answer is it depends on the task, scope, complexity of the task. L
    3 min read
    Difference Between Ash and Bash
    There are various shells that offer different features and better syntax than each other in the UNIX operating system. Ash and Bash are two common shells for this operating system. What is Ash? Ash, originally known as Almquist Shell, also known by other names such as "a Shell" or "Sh" is a lightwei
    2 min read
    Bash Scripting - Difference between Zsh and Bash
    A shell is an environment in which various commands can be executed, it provides an interface between the user and the UNIX system. Basically, a shell is a command-line interpreter which interprets the commands given by the user, it can also read the combination of such commands which is known as a
    2 min read
    Difference between Shell and Kernel
    In computing, the operating system (OS) serves as the fundamental layer that bridges the gap between computer hardware and the user. Two critical components of an operating system are the kernel and the shell. Understanding the relationship between these two components is fundamental to grasping how
    4 min read
    Difference between CLI and GUI
    A Command Line Interface (CLI) and a Graphical User Interface (GUI) are two distinct methods for interacting with computer systems and software. CLI allows users to execute commands by typing them into a terminal or console providing precise control and efficiency but requiring knowledge of command
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences