Intro to the Command Line Interface


DPOE-N | 2022-05-04


with Brendan Coates (he|his)

About Me


gardener, technobabbler, LATU member

archivist specializing in AV and Oral Histories

Agenda



Part 1

History, Context, Objectives


12pm-12:50pm EDT | 9am-9:50am PDT

Overview of the command line
Basic command line use
10min break

Part 2

Intro to Commands


1pm-2pm EDT | 10am-11am PDT

System info
navigation
inputs and outputs

LUNCH


2pm-3pm EDT | 11am-12pm PDT

Part 3

CLI Tools for DigiPres


3pm-3:50pm EDT | 12pm-12:50pm PDT

file movement, rsync
checksums, Bagit
10 minute break

Part 4

Intro to Scripting


4pm-5pm EDT | 1pm-2pm PDT

setup, principles
command sequences, loops
managing scripts

Overview


What are we doing here?
What is "open source" - how is it relevant?
Weren't those readings cool?

Introductions

Breakout Rooms


What's your name/ pronouns/ location?
What do you do for fun? For work?
What's 1 thing that brought you here?

What is the command line?

Historical use

A "terminal" connects to a computer
Only interface before 1973
Bell Labs, UNIX, Bourne Shell
GNU:Bourne Again Shell (bash)

Modern use

"terminal emulator," technically
many terminals to choose from
common interface for servers
ppl will think you're a hacker 😎

What good is it?

more consistency, less "meatdata"
computers don't get bored
connects you to your computing ancestors
instantiate your workflows in code!

Basic Command Structure

software -options arguments

How To Brake

Stopping

Interrupt process:
Ctl+c
Stop process:
Ctl+z

Quit/ Exit

Esc
q

ps aux | grep [proc]
kill [proc]

Finding Help

man pages

help within terminal
official help docs
also available online

Stack Overflow

[software] [what you wanna do]
use exact error text
be mindful of dates

Navigation


PWD

"print working directory"

no flags for this

ls

"list" contents

key flags:
-a = all
-l = long format
-1 = one per line

cd

"change directory"
key arguments:
~/ = home folder
.. = parent directory
- = previous directory

paths

absolute paths:
from drive to file

relative paths:
relative to working directory

whereis and which

return path of search "term"

find installation paths of command

find

like ls but better
key flags:
-type
-name

find

more flags:
-and
-or
*

Users & Permissions


id

display user info

flags:
-n = name
-G = group

sudo

"super user do"
you're admin now

chmod|chown

chmod = change perms
chown = change ownership

I/O, Redirection


prequel

"everything is a file"
...in linux

echo

print to terminal
text -> stdout

stdin

"standard in" = terminal

stdout

"standard out" = also terminal

stderr

"standard error" = again, terminal

pipes

send output to command
common uses:
tail
less
grep

redirects

send output to file
cmd > /dev/null
cmd >> log.txt

&&

sequence commands
only runs cmd2 IF
cmd1 successful

lunch

see you in an hr!

CLI for DigiPres

moving files
doing hashes
BagIt

Moving Files


cp

"copy"
flags:
-R = recursive (subdirs)
-a = timestamps
-i/n = interactive/not
-v = verbose

mv

"move"
renames files/paths
flags:
-i/n = interactive/not

mkdir

"make directory"
flags:
-p = parents
-v = verbose

rsync

sync files/ dirs
flags:
-a = archive mode
-v = verbose
-z = compress
-x = extended attrs

rsync

flags:
--progress
--logfile=path
--exclude

Checksums


Hashes

break file into blocks
read blocks + compute hash
check full file hash

CRC

break file into blocks
read blocks + compute block hash
check block hashes

Checksums


md5sum

generate MD5 hash
flags:
-c = check files

shasum

generate SHA hash
flags:
-a = algorithm
-p = portable
-c = check files

BagIt

Library of Congress + IETF standard
for folder architecture

supports robust verification
of package contents + integrity

grabbags

wrapper for bagit-python
maintained by AMIA OSC
exposes bagit-python to CLI

Scripting

find

execute a command
on output of find

FOR loops

iterate through something
loop thru directory

wrap up & questions

thank you!

and thanks to everyone who made this possible