-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux.tex
More file actions
780 lines (660 loc) · 21.6 KB
/
Copy pathlinux.tex
File metadata and controls
780 lines (660 loc) · 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
\documentclass{beamer}
\mode<presentation>
{
\usetheme{Madrid}
}
\usepackage{graphics, graphicx}
\usepackage{booktabs}
\DeclareGraphicsExtensions{.pdf,.png,.jpg,.gif}
\title{Linux Beginner Guide}
\author{Jaewoong Lee}
\institute[UNIST]
{
Ulsan National Institute of Science and Technology
\medskip
\newline
\textit{jaewoong@unist.ac.kr}
}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Introduction}
In this guide, I assume that you can open a Linux shell in one of these ways:
\begin{enumerate}
\item A current Ubuntu LTS desktop, WSL, or course-provided Linux server
\item A terminal running bash or zsh
\item A basic terminal editor such as Vim, Neovim, or nano
\item A registered SSH public key if the lab uses a remote server
\end{enumerate}
With this guide, you can use and understand a Linux system. \\
The commands are written for a beginner lab in 2026. Your prompt, user name, host name, or Linux distribution may look different, and that is fine.
\end{frame}
\begin{frame}
\frametitle{Overview}
\tableofcontents
\end{frame}
\section{Linux?}
\begin{frame}
\frametitle{Linux?}
\begin{figure}[h!]
\centering
\includegraphics[width=0.4 \linewidth]{figures/linus.jpg}
\caption{Linus Torvalds, Inventor of Linux}
\end{figure}
Linux is a widely used operating system family, alongside Windows and macOS. \\
Linux is open source and is used on servers, cloud systems, laptops, embedded devices, and phones. \\
Android, a mobile operating system, is based on Linux.
\end{frame}
\begin{frame}
\frametitle{Ubuntu?}
\begin{figure}[h!]
\centering
\includegraphics[width=0.3 \linewidth]{figures/ubuntu.jpg}
\caption{Logo of Ubuntu}
\end{figure}
Ubuntu is a beginner-friendly Linux distribution. \\
It is common in classrooms, cloud images, WSL, and personal machines, but most commands in this guide also work on other Linux distributions.
\end{frame}
\section{Remote Server Access}
\begin{frame}
\frametitle{SSH Keys}
For the class server, use key-based SSH access.
\begin{enumerate}
\item Generate a key pair once on your laptop
\item Send only the public key to the instructor or server admin
\item Keep the private key secret
\end{enumerate}
\begin{example}
\$ ssh-keygen -t ed25519 \\
\$ cat $\sim$/.ssh/id\_ed25519.pub \\
\$ ssh yourid@class-server
\end{example}
Password login may be disabled from outside the lab network.
\end{frame}
\begin{frame}
\frametitle{Jump Host}
Some class sessions reach the class server through a jump host. The jump host is only a bridge; do not run your analysis there.
\begin{example}
\$ ssh -J jump-user@jump-host yourid@class-server
\end{example}
In MobaXterm, VS Code, or another SSH client, set the class server as the target and the jump host as the SSH gateway or ProxyJump host. \\
Use the host, port, and account details provided in class. Do not post them publicly.
\end{frame}
\section{Basic Linux Command}
\begin{frame}
\frametitle{Where we start}
\begin{figure}[h!]
\centering
\includegraphics[width=0.5 \linewidth]{figures/1.png}
\caption{Here is where we start}
\end{figure}
After you open a terminal or connect to a server via SSH, you may see a prompt like this. \\
Here is where we start! \\
The text before `@' is the user name, and the text after `@' is the server or computer name.
\end{frame}
\begin{frame}
\frametitle{pwd}
\begin{figure}[h!]
\centering
\includegraphics[width=0.5 \linewidth]{figures/2.png}
\caption{Result of \textit{pwd} Command}
\end{figure}
\textit{pwd} is abbr. of "Print Working Directory". \\
You can see where you are with \textit{pwd} command. \\
Also, "/home/username" is your \textit{home folder}, a.k.a. '$\sim$'.
\end{frame}
\begin{frame}
\frametitle{ls}
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/3.png}
\caption{Result of \textit{ls} Command}
\end{figure}
\textit{ls} stands for "List". \\
\textit{ls} command lists current directory contents. \\
If current directory is empty, the result will be nothing.
\end{frame}
\begin{frame}
\frametitle{Configuration}
Before starting the lab, make a small working directory. No custom dotfiles, shell theme, or plugin setup is required.
\begin{example}
\$ mkdir -p $\sim$/linux-lab \\
\$ cd $\sim$/linux-lab \\
\$ pwd
\end{example}
Note that you should input only the command after '\$'. \\
On the class server, required tools are prepared by the admin. If a command is missing, ask the instructor. \\
On your own Ubuntu or WSL machine only, install basic tools with \textit{sudo apt install vim curl wget screen}.
\end{frame}
\begin{frame}
\frametitle{Configuration \textit{(Cont.)}}
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/4.png}
\caption{Shell Prompt}
\end{figure}
Your prompt may look different from this image. The important part is that you know which directory you are in.
\end{frame}
\begin{frame}
\frametitle{Tip!}
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/5.png}
\caption{Right Command vs. Wrong Command}
\end{figure}
In this screenshot, valid commands are highlighted in green. Treat this as a helpful hint, not as a replacement for reading the command before pressing Enter.
\end{frame}
\begin{frame}
\frametitle{mkdir}
\textit{mkdir} stands for "Make Directory". \\
You can make a directory which named 'test' as following:
\begin{example}
\$ mkdir test \\
\$ ls
\end{example}
\textit{mkdir} returns nothing when it succeeds. Literally, \textit{mkdir} command only makes a directory. \\
You can check that the directory has been made with \textit{ls} command.
\end{frame}
\begin{frame}
\frametitle{cd}
\textit{cd} is abbr. of "Change Directory". \\
You can change your working directory to 'test' as following:
\begin{example}
\$ pwd \\
\$ cd test\\
\$ pwd \\
\end{example}
Also, you can go your home folder at once with \textit{cd}, no matter where you are.
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/6.png}
\caption{\textit{cd} will guide you to home folder}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Tip!}
If you hit the "Tab" key, bash and zsh can complete file names, directory names, and commands. \\
Following example shows what tab completion gives.
\begin{figure}
\centering
\includegraphics[width=0.7 \linewidth]{figures/10.png}
\caption{Shortcut with Tab}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{man and -$ $-help}
You can get detailed information about command as following:
\begin{example}
\$ man ls \\
and/or \\
\$ ls -$ $-help
\end{example}
This guide gives simple information about Linux commands. When you want more detail about a command, use these commands.
\end{frame}
\begin{frame}
\frametitle{Directory Structure}
Try following commands:
\begin{example}
\$ cd test\\
\$ ls -al
\end{example}
Then, you can see like this:
\begin{figure}[h!]
\centering
\includegraphics[width=0.3 \linewidth]{figures/7.png}
\caption{Result of \textit{ls} command}
\end{figure}
All directory has '.' and '..', even though the directory is empty. \\
'.' means current directory itself; and, '..' means parent directory.
\end{frame}
\begin{frame}
\frametitle{touch}
\textit{touch} command make new file or touch the file.
Try following example:
\begin{example}
\$ cd \\
\$ touch t \\
\$ ls
\end{example}
Then, you can see that the file which name 't' has been made.
\begin{figure}[h!]
\centering
\includegraphics[width=0.5 \linewidth]{figures/8.png}
\caption{Result of \textit{touch} Command}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{mv}
\textit{mv} command moves/renames file. \textit{mv} is used as:
\begin{example}
\$ mv SRC(source) DST(destination)
\end{example}
Try following commands:
\begin{example}
\$ mv t tmp \\
\$ ls \\
\$ mv tmp test/ \\
\$ ls
\end{example}
Then, you will realize that the file 'tmp' is gone. I hope that you already know where the file goes. :)
\end{frame}
\begin{frame}
\frametitle{cp}
\textit{cp} command copies SRC to DST. \textit{cp} is used as:
\begin{example}
\$ cp SRC DST
\end{example}
Try following commands:
\begin{example}
\$ cd $\sim$/test/ \\
\$ ls \\
\$ cp tmp tmp2 \\
\$ ls
\end{example}
Then, you can realize that a new file 'tmp2' has been made.
\end{frame}
\begin{frame}
\frametitle{rm}
\textit{rm} stands for 'Remove'. As its name, you can delete files or directories.
\begin{example}
\$ rm tmp2
\end{example}
When you want to delete a directory, use '-r' option:
\begin{example}
\$ rm -r directoryname
\end{example}
There is no way to restore removed files!! Beware what you remove!!
\end{frame}
\begin{frame}
\frametitle{sudo}
\textit{sudo} runs a command with administrator privileges when the server policy allows it. \\
On the lab servers, ordinary users should not rely on \textit{sudo}. Package installation, system settings, service restarts, and ownership changes are admin tasks.
\begin{figure}[h!]
\centering
\includegraphics[width=0.3 \linewidth]{figures/sudo.png}
\caption{XKCD: Sandwich}
\end{figure}
If a command asks for \textit{sudo}, stop and ask the instructor or server admin. Do not try to bypass the policy.
\end{frame}
\section{Edit File with Vim}
\begin{frame}
\frametitle{Editor}
Common choices include nano, Vim/Neovim, Emacs, and VS Code Remote SSH.
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/editor.png}
\caption{Descriptions of Editor}
\end{figure}
This guide uses Vim because it is available on many servers.
\end{frame}
\begin{frame}
\frametitle{Editor \textit{(Cont.)}}
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/curves.jpg}
\caption{Learning Curves among Editors}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{First Meet with Vim}
With these commands, you can make/edit file.
\begin{example}
\$ vim notes.txt
\end{example}
If it is your first time to open Vim, then you may see something like this.
\begin{figure}[h!]
\centering
\includegraphics[width=0.5 \linewidth]{figures/9.png}
\caption{First Time of Vim}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Modes of Vim}
\begin{figure}[h!]
\centering
\includegraphics[width=0.7 \linewidth]{figures/modes.png}
\caption{Three Modes in Vim}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{How to Edit with Vim}
Editing with Vim follows these steps:
\begin{enumerate}
\item Press 'i'
\item Edit the file
\item Press 'ESC'
\item Enter ':w' which means \textit{write}
\item Enter ':q' which means \textit{quit}
\end{enumerate}
\end{frame}
\begin{frame}
\frametitle{Editor Practice (Optional)}
No Vim plugin is required for this lab. If you want a guided practice session, run:
\begin{example}
\$ vimtutor
\end{example}
If \textit{vimtutor} is not installed on your own Ubuntu machine, install Vim with:
\begin{example}
\$ sudo apt install vim
\end{example}
On the class server, ask the instructor instead of using \textit{sudo}.
\end{frame}
\section{IO Redirections}
\begin{frame}
\frametitle{cat}
\textit{cat} stands for con\textbf{cat}enate. \textit{cat} command reads files, and writing them to standard output. \\
Consider following example:
\begin{example}
\$ cd $\sim$/test/ \\
\$ cat tmp
\end{example}
You can see contents of file.
\end{frame}
\begin{frame}
\frametitle{Input/Output to file}
If you want redirect output to file, use following example:
\begin{example}
\$ cat tmp $>$ output
\end{example}
However, this method \textit{overwrites} the contents of file. \\
If you want preserve the file contents, use following:
\begin{example}
\$ cat tmp $>>$ output
\end{example}
Also, $<$ means input from file.
\end{frame}
\begin{frame}
\frametitle{Output to file \textit{Cont.}}
In some cases, you should divide standard output and standard error. \\
In these cases, use following commands:
\begin{example}
\$ commands 1$>$ STDOUT 2$>$ STDERR
\end{example}
\begin{example}
\$ cat tmp 1$>$ ex.stdout 2$>$ ex.stderr
\end{example}
If you want to save both standard output and standard error in one file:
\begin{example}
\$ commands 1$>$log 2$>$\&1
\end{example}
\end{frame}
\begin{frame}
\frametitle{more / less}
\textit{more} and \textit{less} are commands for seeing the contents of file.
Consider following examples:
\begin{example}
\$ more tmp
\end{example}
\begin{example}
\$ less tmp
\end{example}
Also, hit "Q" when you want to leave \textit{more} or \textit{less}.
\end{frame}
\begin{frame}
\frametitle{Pipe}
Use pipe ($|$) to indicate input as output of previous command.
\begin{example}
\$ command1 $|$ command2
\end{example}
The output of command 1 will be the input of command2. \\
Consider following example:
\begin{example}
\$ cat tmp $|$ less
\end{example}
\end{frame}
\section{How to Download from Web}
\begin{frame}
\frametitle{Two Ways for Download}
There are two main ways for download.
\begin{enumerate}
\item curl
\item wget
\end{enumerate}
\end{frame}
\begin{frame}
\frametitle{curl}
\begin{example}
\$ curl https://example.com
\end{example}
\textit{curl} returns to standard output. If you want to get file, consider following:
\begin{example}
\$ curl -L https://example.com -o example.html
\end{example}
\end{frame}
\begin{frame}
\frametitle{wget}
\textit{wget} returns a downloaded file as output.
\begin{example}
\$ wget https://example.com -O example.html \\
\$ ls
\end{example}
\end{frame}
\begin{frame}
\frametitle{gzip}
\textit{gzip} is used for file compression and decompression.
When compressing:
\begin{example}
\$ gzip tmp
\end{example}
When decompressing:
\begin{example}
\$ gzip -d tmp.gz
\end{example}
However, the examples hereinabove delete the original files. If you want \textit{keep} original file, consider following:
\begin{example}
\$ gzip -k tmp
\end{example}
\end{frame}
\begin{frame}
\frametitle{TAR Files}
\textit{TAR} stands for "Tape Archives". \\
Originally, it was used for tape; today, it is used to bundle many files into one archive. \\
TAR.GZ files are commonly used for source code and lab data. Replace LAB-URL with the URL from your instructor:
\begin{example}
\$ wget LAB-URL -O lab-files.tar.gz
\end{example}
(TGZ is for TAR.GZ)
\end{frame}
\begin{frame}
\frametitle{TAR Files \textit{(Cont.)}}
You might think you must decompress the GZ file and then extract the TAR file. However, you can extract a TGZ or TAR.GZ file at once:
\begin{example}
\$ tar -xzf lab-files.tar.gz
\end{example}
Then, you can see the extracted directory with \textit{ls}.
\end{frame}
\section{User Permissions}
\begin{frame}
\frametitle{Permissions}
With the following command, we can know how permissions are set:
\begin{example}
\$ ls -al
\end{example}
\begin{figure}[h!]
\centering
\includegraphics[width=0.4 \linewidth]{figures/11.png}
\caption{File Permissions}
\end{figure}
The way to read this result is following:
\begin{figure}[h!]
\centering
\includegraphics[width=0.5 \linewidth]{figures/permissions.jpg}
\caption{How to Read Permissions}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{chmod}
\textit{chmod} stands for "Change Mode". You can modify permissions of files.
Before input command, you should calculate simple arithmetic:
\begin{figure}[h!]
\centering
\includegraphics[width=0.4 \linewidth]{figures/permissions2.png}
\caption{Simple Arithmetic}
\end{figure}
Then, you will get three digits for permission. Moreover, 660 or 770 are usually used.
\begin{example}
\$ chmod \textcolor{red}{three\_digits} filename
\end{example}
\end{frame}
\begin{frame}
\frametitle{chmod \textit{(Cont.)}}
Or, you can do as followings:
\begin{example}
\$ chmod rwx-$ $-$ $-$ $-$ $-$ $- tmp
\end{example}
\begin{example}
\$ chmod g=rwx tmp
\end{example}
\begin{example}
\$ chmod +x tmp
\end{example}
\end{frame}
\begin{frame}
\frametitle{chown}
\textit{chown} stands for "change ownership". As its name, you can modify ownership of file.
On shared lab servers, changing file owner is usually an administrator task.
When you want to change only USER:
\begin{example}
\$ chown USER tmp
\end{example}
When you want to change both USER and GROUP:
\begin{example}
\$ chown USER:GROUP tmp
\end{example}
\end{frame}
\section{Process Control}
\begin{frame}
\frametitle{Ctrl-C}
When a foreground command is running and you want to stop it, press "Ctrl-C".
\begin{example}
\$ sleep 600 \\
\$ \^{}C
\end{example}
In terminal output, \^{} means "Control"; \^{}C means Ctrl-C. \\
Ctrl-C sends SIGINT, which stands for "signal interrupt". Most command-line programs stop after receiving it.
\end{frame}
\begin{frame}
\frametitle{\&}
Some commands take longer than a few seconds:
\begin{example}
\$ sleep 600
\end{example}
Add '\&' to start the command in the background and get your prompt back:
\begin{example}
\$ sleep 600 \&
\end{example}
The job is still running in this shell. Use \textit{jobs} to see it.
\end{frame}
\begin{frame}
\frametitle{jobs}
\textit{jobs} lists background jobs started from the current shell.
\begin{example}
\$ jobs
\end{example}
\begin{figure}[h!]
\centering
\includegraphics[width=0.5 \linewidth]{figures/12.png}
\caption{Result of \textit{jobs}}
\end{figure}
The number in square brackets is the job number for this shell. Use it with commands such as \textit{fg}, \textit{bg}, or \textit{kill}. \\
If you close the shell, this job list is gone.
\end{frame}
\begin{frame}
\frametitle{kill}
\textit{kill} sends a signal to a process. By default, it asks the process to terminate cleanly.
To stop a background job from the current shell, use its job number:
\begin{example}
\$ kill \%1
\end{example}
The number comes from the \textit{jobs} command.
\begin{example}
\$ kill 12345
\end{example}
Use a PID when the process was not started from the current shell. Only stop processes that belong to you.
\end{frame}
\begin{frame}
\frametitle{nohup}
If SSH disconnects, the shell may send SIGHUP to commands it started. A background command can stop even though you used '\&'. \\
\textit{nohup} tells one command to ignore SIGHUP.
\begin{example}
\$ nohup sleep 600 $>$ sleep.log 2$>$\&1 \&
\end{example}
Without redirection, \textit{nohup} writes output to \textit{nohup.out}. Use it for small, simple commands only. \\
For long analysis or shared CPU/GPU work, submit a Slurm job instead.
\end{frame}
\begin{frame}
\frametitle{screen}
\textit{screen} keeps a terminal session running on the server after SSH disconnects.
\begin{example}
\$ screen -S lab \\
Ctrl-a, then d \\
\$ screen -r lab
\end{example}
Press Ctrl-a, then d inside \textit{screen} to detach. It is not a shell command. \\
Use \textit{exit} when you are done. \textit{screen} keeps the shell alive, but it does not reserve CPU, memory, or GPU. Use Slurm for computation.
\end{frame}
\section{Shared Server Jobs with Slurm}
\begin{frame}
\frametitle{Slurm}
The lab server is shared. CPU, memory, GPU, storage, and time are distributed across all users. \\
Slurm is the job scheduler. It queues your work, starts it when the requested resources are available, and writes output to log files. \\
Use the shell for quick checks and file editing. Use Slurm for long runs, many cores, high memory, or GPU jobs.
\end{frame}
\begin{frame}
\frametitle{Slurm Script}
A Slurm script is a shell script with resource requests at the top. Create \textit{hello-slurm.sh} with your editor, then add:
\begin{example}
\#!/bin/bash \\
\#SBATCH -{}-job-name=linux-lab \\
\#SBATCH -{}-output=slurm-\%j.out \\
\#SBATCH -{}-error=slurm-\%j.err \\
\#SBATCH -{}-time=00:05:00 \\
\#SBATCH -{}-mem=1G \\
\#SBATCH -{}-cpus-per-task=1 \\
hostname \\
sleep 30
\end{example}
\#SBATCH lines define the job name, stdout/stderr log files, wall time, memory, and CPU request.
\end{frame}
\begin{frame}
\frametitle{sbatch}
Submit the script to the queue with \textit{sbatch}:
\begin{example}
\$ sbatch hello-slurm.sh
\end{example}
Slurm prints a job ID, such as "Submitted batch job 12345". Save that ID to track the job and find the output file:
\begin{example}
\$ squeue -u \$USER \\
\$ cat slurm-JOBID.out
\end{example}
\end{frame}
\begin{frame}
\frametitle{squeue}
Check queued and running jobs with \textit{squeue}:
\begin{example}
\$ squeue -u \$USER
\end{example}
Common states:
\begin{enumerate}
\item PD: waiting in the queue
\item R: running
\item CG: completing and writing output
\end{enumerate}
A PD job is not broken; it is waiting for resources or priority. If Slurm does not respond, report it to the instructor or server admin.
\end{frame}
\begin{frame}
\frametitle{scancel}
Cancel a submitted job with \textit{scancel}:
\begin{example}
\$ scancel JOBID
\end{example}
Cancel all of your own queued or running jobs only when you really mean it:
\begin{example}
\$ scancel -u \$USER
\end{example}
The JOBID from \textit{sbatch} is the handle for checking, reading logs, and canceling. Use the all-job cancel command carefully.
\end{frame}
\end{document}