Part 1
Understanding the Shell Prompt
When you log in, the shell greets you with a prompt — a short line of text that tells you who you are, what machine you are on, and that it is ready for your command.
| student | Your username — who is logged in |
| @ | Separator — read as "at" |
| workstation | Hostname — the name of this machine |
| $ | Indicates a regular (non-root) user. Root users see # instead. |
student@workstation $ before continuing.
Part 2
Commands and Options
A Linux command follows a consistent structure:
| command | The program to run |
| -option | Modifies how the command behaves (preceded by a dash) |
| argument | The file, directory, or data the command acts on |
Try a real example — clear your command history:
Here history is the command and -c is the option that clears the saved history list. No output is produced when it succeeds — that is normal.
Part 3
Displaying File Contents
head
Large files are impractical to display all at once. head shows just the first 10 lines — useful for peeking at what a file contains.
The argument here is an absolute path — starting from / (the root of the filesystem) all the way to the file named FAQ.
tail
tail is the counterpart to head. It shows the last 10 lines, which is especially handy for log files where the most recent events appear at the bottom.
Part 4
Copying, Moving, and Removing Files
cp
The cp command copies a file. The destination is the second argument. A single dot . is shorthand for the directory you are currently in.
After this command you will have a personal copy of the FAQ file in your current directory. The original file in /usr/share/doc/bash/ is untouched.
. (dot) — refers to the current directory.Key symbol:
.. (double dot) — refers to the parent directory (one level up).
mv
mv moves (or renames) a file. Unlike cp, the original location no longer has the file after the operation.
The destination ../ means "one directory above the current one." The file is moved there.
/usr/share. Your instructor will advise if a substitute path should be used.
rm
rm removes a file. There is no Recycle Bin — once deleted, the file is gone. The -i option adds an interactive confirmation prompt to protect you from accidents.
Type y and press Enter to confirm. Type n to cancel.
ls to confirm it no longer appears in the directory listing.
Part 5
Keeping Your Terminal Tidy
clear
After several commands the terminal can feel cluttered. clear scrolls all previous output off-screen and places a fresh prompt at the top.
Nothing is deleted — you can still scroll up to see prior output. The keyboard shortcut Ctrl + L does the same thing.
history
The shell keeps a numbered list of every command you have typed. Running history displays it — a great way to review what you did or re-run a command.
To re-run any listed command, type ! followed by its number. For example, !3 re-runs the tail command.
Summary
Commands Covered in This Lab
| Command | What it does | Example |
|---|---|---|
history -c |
Clears the saved command history | history -c |
head |
Shows the first 10 lines of a file | head /usr/share/doc/bash/FAQ |
tail |
Shows the last 10 lines of a file | tail /usr/share/doc/bash/FAQ |
cp |
Copies a file to a destination | cp /usr/share/doc/bash/FAQ . |
mv |
Moves (or renames) a file | mv FAQ ../ |
rm -i |
Deletes a file (asks for confirmation) | rm -i FAQ |
clear |
Clears the terminal screen | clear |
history |
Lists recently used commands | history |
. = current directory ·
.. = parent directory ·
/ = root of the filesystem