Linux Basics¶
Every HPC cluster runs Linux. When you SSH into Unity, you're dropped into a Linux shell: a text-based interface where you control the system by typing commands. There's no file browser, no right-click menu, and you can't use your mouse. Just a prompt, a blinking cursor, and a lot of power.
If you've never used the command line before, this can feel disorienting. This article will give you the vocabulary and hands-on practice you need to navigate confidently.
Interactive first
Before reading the reference sections below, try the hands-on terminal tour. You'll practice the most important commands in a guided, story-driven simulation without needing real cluster access.
The Terminal Tour¶
You've just been given access to Unity. The previous grad student left behind some data on a lab volume. Your mission: find it, understand it, and set up your own workspace.
Enter your NetID below to personalize the simulation, then click SSH into Unity → to begin.
The Shell Prompt¶
When you SSH into Unity, you see something like this:
This is your shell prompt. It tells you:
username: your usernamelogin1: the name of the login node you're connected to~: your current directory (~is shorthand for your home directory)$: you're logged in as a regular user (not root)
Everything you type after $ is a command. Press Enter to run it.
Navigation¶
Where am I? — pwd¶
pwd (print working directory) tells you your current location in the filesystem:
What's here? — ls¶
ls lists the contents of your current directory:
Add flags to get more detail:
| Command | What it does |
|---|---|
ls | List files and directories |
ls -l | Long format; shows permissions, size, date |
ls -a | Show hidden files (those starting with .) |
ls -lh | Long format with human-readable file sizes |
ls /some/path | List a different directory without navigating to it |
Move around — cd¶
cd (change directory) moves you to a new location:
cd /work/pi_chen # absolute path
cd my_project # relative path (inside current dir)
cd .. # go up one level
cd ~ # go home
cd # also goes home
Reading Files¶
Print a file — cat¶
cat prints the entire file to the terminal. Fine for small files; overwhelming for large ones.
Peek at the top — head¶
Peek at the bottom — tail¶
tail results.csv # last 10 lines
tail -n 20 results.csv # last 20 lines
tail -f slurm-12345.out # follow a file as it grows (useful for job logs)
Page through a file — less¶
less opens a scrollable viewer. Use Up / Down to scroll, Space to page down, q to quit, /pattern to search.
File Management¶
Create a directory — mkdir¶
Copy a file — cp¶
cp source.txt destination.txt # copy file
cp source.txt /some/other/directory/ # copy into a directory
cp -r my_dir/ backup_dir/ # copy a whole directory (-r = recursive)
Move or rename — mv¶
There's no Recycle Bin
On Linux, rm deletes immediately and permanently. There is no undo. Double-check your paths before running rm on a shared filesystem.
Delete — rm¶
Searching¶
Search file contents — grep¶
grep searches for a pattern inside files:
grep "PASS" results.csv # lines containing "PASS"
grep -i "pass" results.csv # case-insensitive
grep -n "error" slurm-12345.out # show line numbers
grep -r "TODO" my_project/ # search recursively through a directory
Find files — find¶
find . -name "*.csv" # find all CSV files in current directory
find /work -name "*.bam" # find BAM files in work storage
find . -newer reference.txt # files newer than reference.txt
Getting Help¶
Every command has built-in documentation:
When in doubt, man is your friend.
Paths and the Filesystem¶
Linux uses a single unified filesystem tree rooted at /. There are no drive letters. Everything hangs off /.
/
├── home/
│ └── username/ ← your home directory (~)
├── work/
│ └── pi_chen/ ← your PI group's work directory
├── scratch/ ← fast temporary storage
├── project/ ← allocated shared storage
└── datasets/ ← curated read-only datasets
Absolute vs. relative paths¶
An absolute path starts from / and unambiguously identifies a location regardless of where you currently are:
A relative path is relative to your current directory. If you're already in your home directory:
Special path shortcuts¶
| Shortcut | Means |
|---|---|
~ | Your home directory |
. | Current directory |
.. | Parent directory |
- | Previous directory (cd - goes back) |
Quick Reference¶
| Category | Command | What it does |
|---|---|---|
| Navigation | pwd | Print current directory |
ls | List files | |
ls -la | List all files, long format | |
cd /path | Change directory | |
cd ~ | Go home | |
cd .. | Go up one level | |
| Reading | cat file | Print whole file |
head file | First 10 lines | |
tail file | Last 10 lines | |
less file | Scrollable viewer | |
| Files | mkdir dir | Create directory |
cp src dst | Copy file | |
mv src dst | Move/rename | |
rm file | Delete file (permanent!) | |
| Search | grep pattern file | Search in file |
find . -name "*.csv" | Find files by name | |
| Help | man cmd | Full manual |
cmd --help | Short help |
What's Next¶
With these fundamentals in hand, you're ready to go deeper:
- Editing Files in the Terminal: Edit job scripts and config files with nano or vi
- Linux — Permissions, Pipes & the Environment: File permissions, pipes, redirection, and shell configuration
- Storage on Unity: Understand your home directory, work storage, and scratch space
- Submitting your first job: Put the scheduler to work with
sbatch