Command Line Kung-Fu

Elsa Gonsiorowski

July 10, 2025

Created: 2025-07-07 Mon 18:28

1. Introduction

Read the Documentation

2. SSH

2.1. SSH: Secure SHell

  • Protocol for accessing computer resources across a network
  • an authentication credential, aka "identity"
  • Each key has a "public" and "private" component
  • Computers have an SSH fingerprint
  • WHY? Makes it easier to connect to remote systems

2.2. SSH Config

Lives in ~/.ssh/config

host bridges
  user gonsie
  hostname bridges2.psc.edu

2.3. Fancy SSH Config

Host *
  ControlMaster auto
  ControlPath ~/.ssh/%r@%h:%p
  ControlPersist 12h
  ForwardX11 yes
  ForwardX11Timeout 12h

2.4. SSH Key Creation

ssh-keygen -t rsa -b 4096

Creates:

id_rsa
id_rsa.pub

2.5. SSH Key Installation

ssh-copy-id bridges

2.6. Files in ~/.ssh/

id_rsa
private key file
id_rsa.pub
public key file, share this one!
config
configuration information
known_hosts
list of saved fingerprints of machines you've connected to
authorized_keys
list of ssh keys that are authorized to connect to this system

3. Shell

3.1. Shell Terminology

Shell
operating system user interface, command-line interface
Prompt
line asking for input
Commands
tools/applications/binaries that you can run
Aliases
typing shortcuts

3.2. Shells

sh
A specification of a shell, not an implementation
bash
Bourne-Again Shell
csh
the C Shell
tcsh
enhanced C shell
zsh
the Z Shell
fish
Friendly Interactive SHell

3.3. Shell Syntax

  • variables, loops, string manipulation, wildcards (globs), testing, branching
  • line that asks for input, configurable!
  • shortcut for typing
  • encapsulate complicated (or multiple) shell commands

3.4. Shell dot files

  • Vary depending on the shell
  • loaded upon login (or shell startup depending)

3.5. Environment Variables

  • $USER
  • $SHELL
  • $PATH and $LD_LIBRARY_PATH
  • env command

3.6. .inputrc

"\e[A": history-search-backward
"\e[B": history-search-forward
"\eOA": history-search-backward
"\eOB": history-search-forward
"\C-p": history-search-backward
"\C-n": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on

3.7. Install Dot Files

4. Git Basics

4.1. Raise Your Hand

  • If you've played a video game with "checkpoints"
  • If you've used "Track Changes" (MS Word or Google Docs)
  • If you know you have git installed on your system

4.2. VC Through Naming

phd101212s.png

Open question: Why bother with Version Control?

4.3. Configuring from the Command Line

Software Carpentry: Setting Up Git

$ git config --global user.name "Ada Lovelace"
$ git config --global user.email "ada@lovelace.io"
$ git config --global core.editor "emacs -nw"
$ git config --global init.defaultBranch main

4.4. Help with Config

$ git config --list
$ git config --help
$ cat ~/.gitconfig

4.5. File: ~/.gitconfig

[core]
    editor = emacs -nw
[init]
    defaultBranch = main
[user]
    name = Elsa Gonsiorowski
    email = gonsie@me.com

4.6. Git vs GitHub

  • Git Cheatsheet
  • GitHub Cheatsheet

5. Git Hands On

5.1. Create a repo

cp -r /jet/home/zjupa/programming_challenge ./
cd programming_challenge
git init
git add *
git commit -m "initial commit"

5.2. Share the repo??

5.3. Clone the Repo

6. Build Systems

6.1. Compiling Code

gcc source.c

gcc source.c -o my_program

gcc source.c util.c -o my_program -g -O2 -lboost -I/opt/boost

6.2. Build Tools

  • make
  • ~autotools~
  • CMake
  • Spack or EasyBuild or Conda/pip

6.3. Magical Incantation

./configure # or ccmake
make
make install

7. Other Topics

  • resource schedulers / managers
  • modules
  • moving data: globus, scp, mpifileutils
  • editors
  • nohup, screen, tmux

8. Credits

Created with Emacs, Org Mode, and RevealJS

(using the Robot Lung theme).

View the source.