2  Linux essentials

If you already live in a terminal, skim the tmux section. Everything here is standard Linux; nothing is ARCC-specific except the paths.

2.1 Moving around

pwd                 # where am I?
ls -lh              # list files, human-readable sizes
cd /project/<project>   # go somewhere
cd                  # go home ($HOME)
cd -                # go back to where you just were

Three shortcuts you’ll use constantly: ~ is your home directory, . is “here”, and .. is “up one”. Press Tab to complete a half-typed path.

2.2 Looking at files without opening them

cat file.txt          # dump a whole (small) file
less big.log          # page through a big file; q to quit, / to search
head -n 20 file       # first 20 lines
tail -n 50 file       # last 50 lines
tail -f slurm-123.out # follow a job's output live as it's written

tail -f on a job’s output file shows whether it’s doing anything.

2.3 Editing files

nano is the easy choice — arrow keys work, and shortcuts are listed at the bottom of the screen (^O = save, ^X = exit).

nano submit.sh

vim is powerful but has a learning curve; if you don’t know it, nano is fine for a submit script. For anything bigger, edit on your laptop and use the portal’s file browser, VS Code’s Remote-SSH, or rsync (Section 3.2).

2.4 Finding things

grep -r "account" .          # search file contents recursively
find . -name "*.nc"          # find files by name
find . -size +1G             # find files bigger than 1 GB (great for quota hunts)
du -sh *                     # how big is each thing in this directory?

du -h --max-depth=1 ~ | sort -h finds what’s eating your quota — it includes hidden dirs like ~/.conda and ~/.cache, the usual culprits on the 50 GB home limit (Section 3.1).

2.5 Environment variables and your shell

Your shell remembers settings in variables. A few you’ll meet:

echo $HOME        # /home/<username>
echo $USER        # your username
echo $SCRATCH     # /gscratch/<username> — your scratch space
echo $PATH        # where the shell looks for commands

To make something permanent (say, a handy alias), add it to ~/.bashrc:

alias q='squeue --me'          # see just my jobs
alias proj='cd /project/<project>'

Run source ~/.bashrc (or log out and back in) to apply changes.

2.6 tmux: keep work alive across a dropped connection

When you SSH in and start something, closing your laptop or losing WiFi kills that shell and everything running in it. tmux keeps your session alive on the login node whether or not you’re connected.

tmux new -s work     # start a named session "work"
#   ... do things, launch an interactive job, watch output ...
#   detach with:  Ctrl-b then d
tmux ls              # list your sessions
tmux attach -t work  # reattach later, even from a different computer

The workflow:

  1. SSH into the login node.
  2. tmux new -s work.
  3. Inside tmux, do your editing, submit jobs, launch an interactive session (Section 7.3).
  4. Detach (Ctrl-b then d) and close your laptop. It all keeps running.
  5. Tomorrow, SSH back in and tmux attach -t work — exactly where you left off.
tmux sessions live on one specific login node

MedicineBow has two login nodes (mblog1, mblog2), and ssh medicinebow.arcc.uwyo.edu sends you to whichever is less busy — so you may land on the other one and tmux ls will show nothing. A session lives only on the node where you created it. Note your node from the shell prompt (or run hostname), and reconnect to that exact node — e.g. ssh <username>@mblog1.arcc.uwyo.edu — to find your session again.

tmux is for login-node shells, not batch jobs

A batch job (sbatch, Section 5.2) already runs independently of your connection — log out and it keeps going. tmux is for things that live in your shell: interactive sessions, monitoring, an editor you don’t want to lose.

2.7 Permissions, briefly

You’ll occasionally see chmod and permission strings like -rw-r-----. The main uses are fixing your SSH keys (chmod 700 ~/.ssh && chmod 600 ~/.ssh/*) and making a script executable:

chmod +x run.sh

You have no root / sudo privileges on the cluster. You can’t install system packages or change things outside your own directories, and you don’t need to — everything you install goes in your own space (Section 4.2) or as modules (Section 4.1).