Bash — Get Started
Check Bash installation
# Check if Bash is installed
bash --version
# Check default shell
echo $SHELL
# List available shells
cat /etc/shells
Your first script
#!/bin/bash
# This is a comment
echo "Hello, World!"
echo "Current date: $(date)"
echo "Current user: $(whoami)"
Running scripts
# Method 1: Make executable
chmod +x script.sh
./script.sh
# Method 2: Run with bash
bash script.sh
# Method 3: Source (runs in current shell)
source script.sh
Shebang line
#!/bin/bash # Bash
#!/bin/sh # POSIX shell
#!/usr/bin/env bash # Portable Bash
Essential commands
# File operations
ls -la # List files
pwd # Print working directory
cd /path # Change directory
mkdir dir # Create directory
touch file # Create empty file
cp src dest # Copy
mv src dest # Move/rename
rm file # Remove
rm -rf dir # Remove directory
# Text operations
cat file # Print file contents
head -n 10 file # First 10 lines
tail -n 10 file # Last 10 lines
grep pattern file # Search
wc -l file # Count lines
Mini Practice
- Create a script with the shebang line
- Run it with
chmod +xand./ - Use basic file operations
- Create a script that prints system information
Up Next
In the next lesson, you'll learn about Syntax — Bash's basic syntax.
Related Topics
Frequently Asked Questions about Get Started
What is Get Started in Bash?
Get Started is a fundamental concept in Bash. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Get Started?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Get Started.
Why is Get Started important in Bash?
Get Started is essential for Bash development. Understanding this concept will help you write better code and solve real-world problems more effectively.