Shell Scripting: Bash Basics

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


Let’s learn the fundamentals of using Bash and navigating the command line.

To navigate through the filesystem you will use the ls command. It lists files in the current folder.

ls

You usually start from your home folder (on macOS it’s /Users/yourusername, on Linux it’s /home/yourusername).

To navigate to other folders you use the cd command:

cd Documents

cd .. goes back to the parent folder.

To know where you are, type pwd (pathname of working directory):

pwd

Command Line Editing

When typing commands, you can:

  • Use left/right arrow keys to move the cursor
  • Press backspace to correct mistakes
  • Press enter to execute the command

Useful keyboard shortcuts:

  • ctrl+d - delete the currently selected character
  • ctrl+f - go to the character on the right
  • ctrl+b - go to the character on the left
  • ctrl+a - go to the beginning of the line
  • ctrl+e - go to the end of the line

Autocompletion

Press the tab key to autocomplete file names and commands. Try typing cd Doc and press tab to autocomplete to cd Documents.

If there are multiple matches, Bash will show you the options. Type more characters to narrow down and press tab again.

Common Shell Commands

These are filesystem commands:

  • ls - list files
  • cd - change folder
  • rm - remove a file or folder
  • mv - move a file or rename it
  • cp - copy a file
  • pwd - show the current working directory
  • mkdir - create a folder

For working with files:

  • cat - display file contents
  • tail - show the last lines of a file
  • grep - search for text in files
  • man - show the manual for a command

Editors:

  • nano - simple text editor
  • vim - powerful text editor

Executing Commands

Commands in /bin and other standard locations can be run by name:

ls
pwd

To run an executable in your current folder, prefix it with ./:

./myscript

Or use the full path:

/Users/flavio/scripts/myscript

Command History

Press the up arrow key to navigate through previously entered commands. Press down to go forward in history.

Run the history command to see all commands you’ve entered:

history

Jobs and Processes

When running a long command, you can:

  • ctrl+C - kill the running command
  • ctrl+Z - pause and send to background

Use these commands to manage jobs:

  • jobs - list background jobs
  • fg - bring a job to foreground
  • bg - resume a paused job in background
  • ps - list running processes
  • top - show processes and resource usage
  • kill <PID> - terminate a process

Lessons in this unit:

0: Introduction
1: Introduction to Shells
2: ▶︎ Bash Basics
3: Writing Shell Scripts
4: Variables and Environment Variables
5: Loops and Arrays
6: Shell Script Functions
7: Creating Aliases
8: Tips and Tricks
9: The Fish Shell
10: Persist aliases and other configuration in Fish Shell
11: How to add a path to Fish Shell
12: Fish Shell, how to avoid recording commands to history
13: Fish Shell, how to remove the welcome message
14: How to replace all filenames with space with underscore using a shell script
15: How to update all npm packages in multiple projects that sit in subfolders