Quick Reference Guide

From Research Computing Center Wiki
Revision as of 11:33, 8 November 2021 by Ben (talk | contribs)
Jump to navigation Jump to search

Linux

Below are the minimum Linux definitions, commands, and shortcuts that you should know to do work on an HPC cluster.

Definitions

1. Command - Word or letters typed into a terminal to make a computer do something. Executed by pressing enter after typing the command.

2. Command line - Literally, the line on which your cursor is on in the terminal. Sometimes used to describe the whole experience of not a graphical user interface, i.e. "Command Line Interface" or "CLI".

3. Command prompt - The text at the beginning of the command line, before your cursor. Typically [username@computername].

4. Directory - Another word for "Folder" (just like a folder in Windows or Mac). Often shortened to "dir" in commands, documentation, conversation, etc...

5. Terminal - Category of software that allows you to interact with your computer via commands, and can allow you to connect to a remote computer (via a CLI).

6. Path - The location of a file or directory. A series of subsequent directories to get to some file or directory. e.g., /home/john/file.txt

7. First / (in a path) - The root directory, where everything starts in the Linux file system.

8. Absolute path - a path that is written beginning with / (root)

9. Relative path - a path that is written relative to some other directory (does not begin with /)

10. (Command) Option - extra letter or word (-SomeLetter or --SomeWord) put after a command to modify its behavior.


Commands

Getting Help (most important)

Command Description Examples
command --help Print a commands help output to the terminal ls --help
man command Read a command's manual (press q to exit) man ls

Directories

Command Description Examples
ls List the contents of a particular directory (current dir if no path specified) ls /scratch/MyID
mkdir Make a new directory at the specified path mkdir /scratch/MyID/workdir
cd Change directory to a particular directory (personal /home dir if no path specified) cd /scratch/MyID/workdir
rmdir Remove an empty directory rmdir tmpdir

Files

Command Description Examples
nano Create or edit a file with nano (to save and exit: ctrl + x, y, enter) nano sub.sh
cat Print the contents of a file to the terminal (better for shorter files) cat slurm-42342.out
less View the contents of a file (better for longer files) less slurm-42342.out
cp Copy a file or files (cp sourcepath(s) destinationpath) cp /scratch/MyID/workdir/sub.sh /work/labgroup
rm Remove a file or files rm oldfile.txt
rm -r Remove a directory and all of its contents, recursively (starting with the last dir in the path) rm -r /home/MyID/olddir

Back to Top

Shortcuts

Linux

Shortcut Description
ctrl + l (lowercase L) Clear your terminal screen (scroll up to see previous output)
up/down arrow keys Cycle through previously entered commands
esc, . (escape, then period) Cycle through previous arguments to commands
ctrl + w Backspace typed text on the command line, one word at a time
ctrl + c Cancel typed text on the command line

less

Shortcut Description
shift + g Go to the end of file
gg Go to the beginning of file
-N then enter Display/hide line numbers
/SomePattern Search forward through a file for SomePattern (/ then enter to keep searching forward for the same pattern)
?SomePattern Search backwards through a file for SomePattern (? then enter to keep searching forward for the same pattern)
q Exit less

Back to Top

Slurm

Below are the minimum Slurm commands that you should know to do work on an HPC cluster. The first table are default Slurm commands. The next table are GACRC pre-formatted wrapper scripts of the Slurm commands to provide more information and flexibility.

Default Slurm Commands

Command Description Examples
sbatch Submit a submission script to the cluster sbatch sub.sh
squeue Check status currently running jobs (--me for only your jobs) squeue --me
sacct -X Check status of your jobs started since midnight of current day (-X for one line per job) sacct -X
sacct -X -S yyyy-mm-dd Check status of your jobs since yyyy-mm-dd sacct -X -S 2021-10-20
sacct -j jobID Check status of a particular job sacct -j 234213
scancel jobID Cancel one of your running jobs scancel 456781
sinfo Check the status of partitions sinfo -p batch

GACRC Slurm Commands

Command Description/Slurm Equivalent Examples
interact Start an interactive job. (Same as qlogin but with more flexibility) interact -c 4 --mem 10gb --time 01:00:00
sq squeue sq --me
sacct-gacrc -X sacct sacct-gacrc -X