Introduction to the Linux Terminal

What Is the Terminal? Understanding the Shell and Command Line Interface
The Terminal (The Window)
terminal emulator
accepts keystrokes and displays text on screen
does not process commands
only forwards commands and receives responses

The Shell (The Brain)
app called the Shell runs in the terminal
Shell is the command interpreter
text uses Bash shell (Bourne Again SHell)

The Command Line (The Concept)
CLI provides interaction with computer using text

The Restaurant Analogy
GUI is the menu
limited to what is offered
the Shell is the head chef

terminal provides precision and power

Opening and Using the Terminal
Focus
terminal only listens when it has focus

The Interaction Loop
terminal uses RELP (Read, Evaluate, Print, Loop)
  1. type a command
  2. press Enter
  3. shell reads the command
  4. shell executes the command
  5. shell prints result to the screen
  6. shell prints a new prompt
Understanding the Prompt: User, Host, and Working Directory
standard Ubuntu prompt
username@computername:~$
username is active user account
@ separates username from the computername
compuername name of host computer
location - current location in file system
the ~ (tilde) represnts the home directory
privilege level
  • $ logged in a standard user
  • # logged in as root
Your First Commands: echo, date, whoami, pwd
echo
simplest command
repeats what was entered back to the screen

date
terminal replies with current day, date, time and timezone
Mon Oct 27 10:30:15 EDT 2025
whoami
system returns the current username
odd because the prompt already contains the username

pwd (Print Working Directory)
can't always see the full path in the prompt
returns current directory
/home/yourusername
Command Structure: Commands, Options, and Arguments
most commands use this structure
Command + Options + Arguments
  • command is the verb
  • argument is the noun
  • option (flags/switches) is the adverb
    usually preceeded by a hyphen

The Basic Command
ls
lists files in current directory

Adding an Argument
ls /bin
lists files in the /bin directory

Adding an Option
ls -l
option -l calls for 'long format'
returns a list with
  • permissions
  • owners
  • file sizes
  • dates
Putting it All Together
ls -l /bin
combined command
list (verb) the contents of the /bin folder (noun) using the long format (adverb)
Short vs Long Options
short options use a single hyphen
long options use two hyphens

Case Sensitivity
Linux is case-sensitive

Getting Help: man Pages, --help, and info
Linux has thousands of commands
sysadmin's skills are not knowing the answer but knowing how to find the answer
Linux has built-in encyclopedia called Manual Pages (man pages)

Using man
to learn more about the ls command enter
man ls
output will show
  • name of command
  • synopsis of command
  • description
followed by a list of the various options
to exit the manual page press the q key (Quit)

Using --help
man page can be too detailed
for a quick cheat sheet
most commands support a --help option
date -- help
produces quick summary of how to use the command

Using whatis
whatis provides a one sentence description of the command's function
whatis cal
provides the result
cal (1) - displays a calendar and the date of Easter.
Command History and Shortcuts: Arrow Keys, history, and Ctrl Combinations
lazy system administrators are good system administrators
should never type the same long command twice if it can be avoided
the terminal has several features designed to save keystrokes

The Up Arrow (Time Travel)
allows cycling through command history

The history Command
history
returns a numbered list of past commands
to rerun listed command #50 enter
!50
Tab Completion (The Superpower)
the shell is smart
  1. enter who but do not press Enter
  2. press Tab key twice
  3. system will suggest commands starting with who

with a file
  1. enter ls Do but do not press Enter
  2. press Tab key once
  3. if a Documents folder exists the shell with automatically complete the command

if multiple folders start with Do (Documents and Downloads) nothing will happen
shell doesn't know the user's intent
pressing Tab twice and all options will be listed
type next letter (c or w) and press Tab again
shell will complete the command

Control Key Options
a few shortcuts
  • Ctrl + C (Cancel) - terminates the current command
  • Ctrl + L (Clear) - clears the screen
  • Ctrl + D (Exit) - closes the shell

Best Practices for Terminal Use
to be safe and efficient
  1. Read Before Enter - scan command one more time before pressing Enter
  2. Don't Blindly Copy and Paste - understand the command being entered
  3. Use Tab Completion - a safety net
    if Tab does nothing the wrong apth is being entered
  4. Respect Root - commands starting with sudo grant administrative privileges
    know what you're doing
  5. Customize Your Profile - ensure font size is large enough to read comfortably
Summary
  • The Shell - program which interprets commands
  • The Prompt - user@host:~$ provides context. ~ is home. $ is a normal user
  • Case Sensitivity - File and file are different
  • Structure - commands usually follow the format
    command -options arguments
  • Man Pages - type man command to read the manual
  • Tab Completion - auto-complete commands and filenames
  • Ctrl + C - stops a runnig commad immediately
index