← All Resources
Linux Command Reference
The essential shell commands you'll use throughout the course.
Navigation
| Command | What it does |
|---|---|
pwd | Print the current directory |
cd my_project/ | Change into a directory |
cd .. | Go up one directory |
ls | List files |
ls -la | List files, including hidden ones, with details |
Files and directories
| Command | What it does |
|---|---|
mkdir simulation_01 | Create a directory |
touch notes.txt | Create an empty file |
cp topol.top backup/ | Copy a file |
mv old.gro new.gro | Rename or move a file |
rm file.log | Delete a file (no undo - be careful) |
rm -r old_run/ | Delete a directory and its contents |
Viewing files
| Command | What it does |
|---|---|
cat file.mdp | Print an entire file to the screen |
less file.log | Scroll through a large file (q to quit) |
head -n 20 file.log | Show the first 20 lines |
tail -n 20 file.log | Show the last 20 lines |
tail -f md.log | Watch a file update live as a run writes to it |
Searching
| Command | What it does |
|---|---|
grep "error" md.log | Find lines containing "error" |
grep -i "warning" md.log | Same, but case-insensitive |
grep -r "TODO" . | Search recursively through every file in a folder |
Permissions and processes
| Command | What it does |
|---|---|
chmod +x script.sh | Make a script executable |
top | Live view of running processes and CPU/memory use |
ps aux | List all running processes |
kill 12345 | Stop a process by its ID |
Redirection and pipes
| Symbol | What it does |
|---|---|
command > file.txt | Write output to a file (overwrite) |
command >> file.txt | Append output to a file |
command1 | command2 | Send the output of one command into another |
Example: gmx mdrun -deffnm em > run.log 2>&1 runs a simulation and saves all its output (including errors) to run.log.
Archives
| Command | What it does |
|---|---|
tar -czvf archive.tar.gz folder/ | Compress a folder into a .tar.gz archive |
tar -xzvf archive.tar.gz | Extract a .tar.gz archive |
A note on case-sensitivity
Linux paths are case-sensitive. Topol.top and topol.top are two different files - a very common source of confusing "file not found" errors when following along with a tutorial.