Bash Get Started

Open a terminal, learn to read the prompt, and start running commands interactively in Bash.

Opening a Terminal

A terminal (or terminal emulator) is the application that gives you a window to type commands into. On most Linux desktops you can open one with Ctrl+Alt+T, on macOS you use the Terminal app or iTerm2, and on Windows you can use Windows Terminal with WSL to get a real Bash environment.

Once open, the terminal starts a shell and shows you a prompt, a short line of text like user@host:~$ that tells you who you are, which machine you are on, and where you currently are in the filesystem, followed by a symbol that invites you to type.

Reading the Command Prompt

  • A dollar sign $ at the end of the prompt means you are a regular user
  • A hash sign # at the end of the prompt means you are the root (administrator) user
  • A tilde ~ in the prompt is shorthand for your home directory
  • The prompt text itself is controlled by the PS1 shell variable and can be customized

Basic Interactive Commands

$ whoami
alex
$ pwd
/home/alex
$ date
Thu Jul 16 10:42:03 UTC 2026

Commands with Arguments

$ echo Hello there
Hello there
$ ls -1
Documents
Downloads
Pictures
Note: Press the Up arrow to recall previous commands from your history, and press Tab to auto-complete file names, directory names, and even command names.

Running Commands Interactively

When you type a command and press Enter, Bash parses the line, locates the program you named, runs it, waits for it to finish, prints anything it writes to the screen, and then returns you to the prompt so you can type the next command. Every command also reports back an exit status when it finishes.

Checking the Exit Status

$ ls /etc/hostname
/etc/hostname
$ echo $?
0
$ ls /no/such/path
ls: cannot access '/no/such/path': No such file or directory
$ echo $?
2
ShortcutEffect
Ctrl+CInterrupt (kill) the currently running command
Ctrl+DSend end-of-file, closing the shell or current input
Ctrl+LClear the terminal screen
Ctrl+RSearch backwards through command history
TabAuto-complete commands, files, and directories

Exercise: Bash Get Started

What is the purpose of the "#!/bin/bash" line at the top of a script?