Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH

Bash Tutorial

Learn Bash

Bash is used to write scripts and run commands on Linux systems.

It helps automate tasks, manage system operations, and boost productivity.

Start learning Bash now »

Understanding Shells

A shell is a text-based interface that lets you talk to your computer.

There are different types of shells, but Bash (Bourne Again SHell) is the most popular because it's powerful and easy to use.

Types of Shells:

  • Bourne Shell (sh): The original Unix shell, developed by Stephen Bourne.
  • C Shell (csh): Known for its C-like syntax, popular for interactive use.
  • Korn Shell (ksh): Combines features of sh and csh, offering advanced scripting capabilities.
  • Bash (Bourne Again SHell): An improved version of sh, with additional features like command history and tab completion.

Why Use Bash?

  • It is widely available on Unix/Linux systems, making scripts portable.
  • Supports powerful scripting features, including loops, conditionals, and functions.
  • Provides command history and tab completion for ease of use.
  • Can be integrated with other Unix/Linux tools for automation.

Learning by Examples

In this tutorial, we will show you Bash commands like this:

Example

bash --version
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

For new users, using the terminal view can seem a bit complicated.

Don't worry! We will keep it really simple, and learning this way gives you a good grasp of how Bash works.

In the code above, you can see commands (input) and output.

Lines like this are commands we input:

Example

bash --version

Lines like this are the output/response to our commands:

Example

GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

In general, lines with $ in front of it is input. These are the commands you can copy and run in your terminal.


Bash Exercises

Many chapters in this tutorial end with an exercise where you can check your level of knowledge.

See all Bash Exercises



Bash Quiz

Learn by taking a quiz! The quiz will give you a signal of how much you know about Bash.

Start Bash Quiz


Track Your Progress

Create a free W3Schools account and get access to more features and learning materials:

  • CheckmarkView your completed tutorials, exercises, and quizzes
  • CheckmarkKeep an eye on your progress and daily streaks
  • CheckmarkSet goals and create learning paths
  • CheckmarkCreate your own personal website

Sign Up for Free

Note: This is an optional feature. You can study at W3Schools without creating an account.


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.