Skip to content

Commit ee070e6

Browse files
committed
Merge branch 'main' into scripting_revision_jh
2 parents b64e4d3 + 07a9fb7 commit ee070e6

5 files changed

Lines changed: 89 additions & 65 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# Linux Command Line 101 - September 2025
1+
# Linux Command Line 101 - 20 October 2025
22

33
## Course description
44

5-
This course is given under <a href="_https://www.naiss.se/" target="_blank">NAISS</a>, by staff working at the branches located at <a href="https://www.uu.se/centrum/uppmax/" target="_blank">UPPMAX</a>, <a href="https://www.lunarc.lu.se/" target="_blank">LUNARC</A>, and <a href="https://www.hpc2n.umu.se/" target="_blank">HPC2N</a>.
5+
This course is given under <a href="_https://www.naiss.se/" target="_blank">NAISS</a>, by staff working at the branches located at <a href="https://www.uu.se/centrum/uppmax/" target="_blank">UPPMAX</a>, <a href="https://www.lunarc.lu.se/" target="_blank">LUNARC</A>, <a href="https://www.hpc2n.umu.se/" target="_blank">HPC2N</a>, and <a href="https://www.c3se.chalmers.se/" target="_blank">https://www.c3se.chalmers.se/</a>.
66

77
This course is an introduction to Linux, which is what is used on most Swedish HPC centers and indeed on the vast majority of HPC clusters worldwide.
88

99
It is meant for beginners to the Linux operating system.
1010

11-
The registration and schedule is here: https://www.hpc2n.umu.se/events/courses/2025/fall/1/intro-linux
11+
The registration and schedule is here: https://www.hpc2n.umu.se/events/courses/2025/fall/2/intro-linux
1212

1313
Materials: Clone this repo or download a zip of the material (click the green "Code" button then pick "Download ZIP").
1414

15-
Lecture recordings from a previous instance: https://www.youtube.com/watch?v=ScMjWTZvtag&list=PL6jMHLEmPVLzoudy66m5isl2LD-YY_05L
15+
Lecture recordings from a previous instance: https://youtube.com/playlist?list=PL6jMHLEmPVLxLh5h2JTe6fFZ0rJx0uO1a&si=SlpCKVcZf8Fy43-H
1616

1717
**Lecture recordings from the current course will be posted to HPC2N's YouTube page:** https://www.youtube.com/user/HPC2N
1818

19-
Date: 22 September 2025
19+
Date: 20 October 2025
2020

2121
Time: 09:00-12:00
2222

‎docs/filesystem.md‎

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ This section will be a basic overview of the Linux filesystem concepts, not an i
2121

2222
The Linux filesystem directory structure starts with the top root directory, which is shown as <code>/</code>. Below this are several other standard directories. Of particular interest are <code>usr/bin</code>, <code>home</code>, <code>usr/lib</code>, and <code>usr/lib64</code>. A common directory which you will also often find is <code>usr/local/bin</code>.
2323

24-
The picture on the right shows typical subdirectories under <code>/</code> (note that the command 'tree' does not work at all HPC centers, though it does work on Tetralith - see the page [tree](../tree) under "Extras section for how to install if it is missing). Some of the directories have a **symbolic link** to a different name - this is often done to make it quicker to write, but can also be for compatibility reasons since some software have hardcoded paths.
24+
The picture on the right shows typical subdirectories under <code>/</code> (note that the command `tree` does not work at all HPC centers, though it does work on Tetralith---see the page [tree](../tree) under the "Extras" section for how to install if it is missing). Some of the directories have a **symbolic link** to a different name---this is often done to make it quicker to write, but can also be for compatibility reasons since some software have hardcoded paths.
2525

2626
!!! Note
2727

28-
The ``path`` or ``pathname`` is the representation of the location of a file or folder/directory on a computer file system.
29-
28+
The `path` or `pathname` is the representation of the location of a file or folder/directory on a computer file system.
3029

3130
- **/** is the root of the directory structure on a Linux filesystem
3231
- **/usr/bin** contains (most) of the system-specific binaries
@@ -35,24 +34,26 @@ The picture on the right shows typical subdirectories under <code>/</code> (note
3534
- **/usr/lib** holds kernel modules and shared library images needed to boot the system and run commands in the root filesystem
3635
- **/usr/lib64** is the same as **/usr/lib**, just for 64-bit libraries
3736

38-
User-installed binaries are often located in **/opt**.
37+
User installed binaries are often located in **/opt**.
3938

4039
The file system could also be illustrated like this:
4140

4241
![folders of filesystem structure](images/filesystem-folders.png){: style="width: 500px;float: left"}
4342

4443
!!! warning "Note"
4544

46-
The character ``/`` can be
45+
The character `/` can be
4746

4847
1. the root directory, if it is at the front of a file or directory name
4948
2. a separator if it appears inside a path.
5049

5150
!!! note
5251

53-
If you are on a local cluster, on an HPC center, etc. where you are not root, you will as default be in your home directory when you login. You can use ``cd ..`` a couple times to go to the root of the system and do ``tree`` there if you want, or do ``tree`` in your home directory (you can always return there with just ``cd``).
52+
If you are on a local cluster, on an HPC center, etc. where you are not root, you will as default be in your home directory when you login. You can use `cd ..` a couple times to go to the root of the system and do `tree` there if you want, or do `tree` in your home directory (you can always return there with just `cd`).
5453

55-
Running ``tree`` in ``/`` on a supercomputing center will probably give a very large/long output!
54+
!!! caution
55+
56+
Running `tree` in `/` on a supercomputing center will probably give a very large/long output!
5657

5758
### Home folders on Tetralith
5859

@@ -63,23 +64,23 @@ The above shows an illustration where the home folders are emphasized.
6364

6465
## Your home directory
6566

66-
When you login to the computer (as a non root user), you will end up in your home directory.
67+
When you login to the computer (as a non root user), you will end up in your home directory. At most HPC centers, your home directory will appear as `~` in the terminal prompt, and can also be used in commands instead of having to type out `/home/YOUR_USERNAME`.
6768

68-
The ``path`` to your home directory varies somewhat. Here are some examples for me:
69+
The `path` to your home directory varies somewhat. Here are some examples for me:
6970

70-
- Tetralith: ``/home/x_birbr``
71-
- Kebnekaise: ``/home/b/bbrydsoe``
72-
- Cosmos: ``/home/bbrydsoe``
73-
- My laptop, ncc-1701: ``/home/bbrydsoe``
74-
- My home desktop, defiant: ``/home/bbrydsoe``
71+
- Tetralith: `/home/x_birbr`
72+
- Kebnekaise: `/home/b/bbrydsoe`
73+
- Cosmos: `/home/bbrydsoe`
74+
- My laptop, ncc-1701: `/home/bbrydsoe`
75+
- My home desktop, defiant: `/home/bbrydsoe`
7576

7677
!!! note
7778

78-
You can always use the command ``pwd`` to see the actualy path!
79+
You can always use the command `pwd` to see the path to your current working directory!
7980

80-
You will always return to your home directory by giving the command ``cd`` and pressing enter.
81+
You can also always return to your home directory by giving the command `cd` and pressing `enter`.
8182

82-
There are is also an "environment variable" that can be used as shortcut for the path: ``$HOME``. We will talk more about (environment) variables later.
83+
There are is also an "environment variable" that can be used as shortcut for the path: `$HOME`. We will talk more about (environment) variables later.
8384

8485
## pwd
8586

@@ -119,7 +120,7 @@ You can use this to find out which directory you are in.
119120
[bbrydsoe@cosmos1 ~]$
120121
```
121122

122-
### Example, in a directory named ``testdir``
123+
### Example, in a directory named `testdir`
123124

124125
On Tetralith, user ``x_birbr``:
125126

@@ -129,7 +130,7 @@ On Tetralith, user ``x_birbr``:
129130
[x_birbr@tetralith3 testdir]$
130131
```
131132

132-
### Example, in subdirectory ``mydir`` under directory ``testdir``
133+
### Example, in subdirectory `mydir` under directory `testdir`
133134

134135
On Tetralith, user ``x_birbr``:
135136

@@ -141,7 +142,7 @@ On Tetralith, user ``x_birbr``:
141142

142143
## ls - listing files/directories
143144

144-
The ls command is used to list files. If you just give the command "ls" with no flags it will list all files in the current directory except for hidden files.
145+
The `ls` command is used to list files. If you just give the command `ls` with no flags it will list all files in the current directory except for hidden files.
145146

146147
<div>
147148
```bash
@@ -260,35 +261,40 @@ Wild cards are also called "glob" or "globbing" patterns.
260261

261262
Globs, also known as glob (or globbing) patterns are patterns that can expand a wildcard pattern into a list of pathnames that match the given pattern.
262263

263-
On the early versions of Linux, the command interpreters relied on a program that expanded these characters into unquoted arguments to a command: ``/etc/glob`` .
264+
On the early versions of Linux, the command interpreters relied on a program that expanded these characters into unquoted arguments to a command: `/etc/glob`.
264265

265266
<br>
266267

267268
**Common wildcards**
268269

269-
- **?** represents a single character
270-
- **\*** represents a string of characters (0 or more)
271-
- **[ ]** represents a range
272-
- **{ }** the terms are separated by commas and each term must be a wildcard or exact name
273-
- **[!]** matches any character that is NOT listed between the [ and ]. This is a logical NOT.
274-
- **\** specifies an "escape" character, when using a subsequent special character.
270+
- **`?`** represents a single character.
271+
- **`*`** represents a string of characters (0 or more).
272+
- **`[ ]`** represents a range of alphanumeric characters in ascending order.
273+
- **`{ }`** the terms are separated by commas and each term must be a wildcard or exact name.
274+
- **`[!]`** matches any character that is NOT listed between `[!` and `]`. This is a logical NOT.
275+
- **`\`** specifies an "escape" character, when using a subsequent special character.
275276

276277
!!! Warning
277278

278279
You may need quotation marks around some wildcards as well.
279280

281+
!!! Warning
282+
283+
Wildcards are typically case-sensitive by default. The `[]` expression in particular treats the set of all uppercase characters as preceding the set of all lowercase characters. For example `[T-g]` will match all uppercase letters from "T" through "Z" and all lowercase letters from "a" through "g", but will not include uppercase "G" or lowercase "t".
284+
285+
Many relevant commands, like `ls`, have an `-i` flag to ignore case.
286+
280287
!!! tip "Try some of the commands below"
281288

282289
Useful files for these examples are found in ``exercises/patterns``
283290

284-
285291
!!! Example "Some examples of the use of wildcards"
286292

287293
```bash
288294
myfile?.txt
289295
```
290296

291-
This matches myfile0.txt, myfile1.txt,... for all letters between a-z and numbers between 0-9. Try with ``ls myfile?.txt``.
297+
This matches myfile0.txt, myfile1.txt,... for all letters from A to z and numbers from 0 through 9. Try with ``ls myfile?.txt``.
292298

293299
```bash
294300
r*d
@@ -306,34 +312,34 @@ Wild cards are also called "glob" or "globbing" patterns.
306312
a[d-j]a
307313
```
308314

309-
This matches ada, afa, aja, ... and any three letter word that starts with an a, ends with an a, and has any character from d to j in between. Try with ``ls a[d-j]a``.
315+
This matches ada, afa, aja, ... and any three letter word that starts with an a, ends with an a, and has any character from d to j in between (but no capital letters). Try with ``ls a[d-j]a``.
310316

311317
```bash
312318
[0-9]
313319
```
314320

315-
This matches a range of numbers from 0 to 9.
321+
This matches a range of numbers from 0 through 9.
316322

317323
```bash
318324
cp {*.dat,*.c,*.pdf} ~
319325
```
320326

321-
This specifies to copy any files ending in .dat, .c, and .pdf to the user's homedirectory. No spaces are allowed between the commas, etc. You could test it by creating a matched file in ``patterns`` directory with ``touch file.c`` and running the above command to see it only copies that one from the ``patterns`` directory.
327+
This command copies any files ending in .dat, .c, and .pdf to the user's home directory. No spaces are allowed between the commas, etc. You could test it by creating a matching file in the `patterns` directory with `touch file.c` and running the above command to see it only copies that one from the `patterns` directory.
322328

323329
```bash
324330
rm thisfile[!8]*
325331
```
326332

327-
This will remove all files named thisfile*, except those that has an 8 at that position in it's name. Try running it in the ``patterns`` directory! Do ``ls`` before and after to see the change. Remember, you can always recreate the directory ``patterns`` by untar'ing it again.
333+
This will remove all files named `thisfile*`, except those that have an 8 at that position in their name. Try running it in the `patterns` directory! Do `ls` before and after to see the change. Remember, you can always recreate the directory `patterns` by untarring it again.
328334

329335
## cd - changing directory
330336

331-
The command ``cd`` is used to change directory.
337+
The command `cd` is used to change directory.
332338

333-
- **cd**: Go to your home directory ($HOME)
334-
- **cd DIR**: Change directory to DIR (whatever path you specify)
335-
- **cd ..**: Change directory to the parent directory of the current directory
336-
- **cd -**: go back to the previous working directory
339+
- **`cd`** or **`cd ~`**: Go to your home directory ($HOME)
340+
- **`cd DIR`**: Change directory to DIR (whatever path you specify)
341+
- **`cd ..`**: Change directory to the parent directory of the current directory
342+
- **`cd -`**: go back to the previous working directory
337343

338344
!!! example
339345

@@ -342,16 +348,16 @@ The command ``cd`` is used to change directory.
342348
![folders of exercises directory structure](images/exercises-folders.png){: style="width: 500px;float: left"}
343349
<br><br style="clear: both;">
344350

345-
Remember, ``$HOME`` is an *environment variable* which gives a shortcut to your home directory.
351+
Remember, `$HOME` is an *environment variable* which gives a shortcut to your home directory.
346352

347-
**NOTE** if you are on Tetralith and placed the exercises under ``/proj/linux-intro/users/USERNAME`` then ``$HOME`` would be replaced by that path.
353+
**NOTE** if you are on Tetralith and placed the exercises under `/proj/linux-intro/users/USERNAME` then `$HOME` would be replaced by that path.
348354

349-
To change to the directory ``exercises`` when you are in your home directory, you do
355+
To change to the directory `exercises` when you are in your home directory, you do
350356
```bash
351357
cd exercises
352358
```
353359

354-
To then change to the directory ``testdir1`` you do
360+
To then change to the directory `testdir1` you do
355361
```bash
356362
cd testdir1
357363
```
@@ -379,7 +385,7 @@ The command ``cd`` is used to change directory.
379385

380386
The path with reference to your current directory is called the relative path. A relative path only explicitly specifies sub-directories of your current directory, leaving the part of the path from the root to the current directory implicit.
381387

382-
!!! note "Keypoints"
388+
!!! summary
383389

384390
- Your home directory is generally located in ``/home/USERNAME`` or ``/home/U/USERNAME``
385391
- Your home directory is also stored as the environment variable ``$HOME``

‎docs/images/shell-logo_small.png‎

4.75 KB
Loading

‎docs/index.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@
7575
| 9:00 | Welcome+Syllabus | |
7676
| 9:10 | Introduction to Linux, motivation | Lecture |
7777
| 9:25 | The command line (CLI) | Lecture+code along |
78-
| 9:45 | Navigating the File System | Lecture+code along+exercise |
79-
| 9:55 | Modifying the file tree | Lecture+code along+exercise |
80-
| 10:05 | Editors | Lecture+code along |
81-
| 10:20 | BREAK | |
82-
| 10:35 | Piping | Lecture+code along+exercise |
83-
| 10:55 | Finding patterns | Lecture+code along+exercises |
84-
| 11:15 | Scripting | Lecture+code along |
85-
| 11:30 | Hints and tricks | Lecture+code along |
86-
| 11:45 | More time for exercises | |
78+
| 9:40 | Navigating the File System | Lecture+code along+exercise |
79+
| 10:05 | Modifying the file tree | Lecture+code along+exercise |
80+
| 10:25 | BREAK | |
81+
| 10:40 | Editors | Lecture+code along |
82+
| 10:50 | Piping and filters | Lecture+code along+exercise |
83+
| 11:10 | Finding patterns | Lecture+code along+exercises |
84+
| 11:25 | Scripting | Lecture+code along |
85+
| 11:40 | Hints and tricks | Lecture+code along |
8786
| 11:55 | Summary | |
8887
| 12:00 | END | |
8988

‎docs/patterns.md‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ See ``man grep`` for more options.
5252

5353
A good file to use here is ``fil.txt`` in the ``exercises/patterns`` directory. You will also use ``newfile.txt`` and ``fil.txt`` in the same directory.
5454

55+
In the following examples/exercises replace the string ``FILE`` with the file name (single search) or the path to the
56+
folder (recursive search).
57+
5558
!!! Example "Find the pattern 'word' in FILE"
5659

5760
```bash
@@ -64,6 +67,8 @@ See ``man grep`` for more options.
6467
grep -rine 'word' path/to/dir
6568
```
6669

70+
**Exercises**
71+
6772
!!! Exercise "Try finding the pattern ``string`` in ``newfile.txt``"
6873

6974
This file is also located in the ``exercises/patterns`` directory.
@@ -72,19 +77,25 @@ See ``man grep`` for more options.
7277

7378
![grep string](images/grepstring.png){: style="width: 400px;float: right;padding: 3px;}
7479
75-
!!! Example "Find the instances of the word 'string' in file.txt and count them"
80+
!!! Exercise "Search for instances of the word 'string' in file.txt and count them"
81+
82+
??? Solution "Click to reveal solution"
7683

7784
```bash
7885
grep -o -i string file.txt | wc -l
7986
```
8087

81-
!!! Example "Find the lines with instances of 'string' in file.txt and output them to file.out"
88+
!!! Exercise "Search for the lines with instances of 'string' in file.txt and output them to file.out"
89+
90+
??? Solution "Click to reveal solution"
8291

8392
```bash
8493
grep string file.txt > file.out
8594
```
8695

87-
!!! Example "Find the lines with instances of 'string' in file.txt and append them to file.out"
96+
!!! Exercise "Search for the lines with instances of 'string' in file.txt and append them to file.out"
97+
98+
??? Solution "Click to reveal solution"
8899

89100
```bash
90101
grep string file.txt >> file.out
@@ -115,19 +126,23 @@ find [path] [options] [expression]
115126

116127
For more options, check ``man find``
117128

118-
**Examples**
129+
**Exercises**
119130

120131
!!! tip "Try yourself"
121132

122133
You could do the searches inside ``exercises`` directory or inside ``exercises/patterns`` directory.
123134

124-
1. Find the file ``myfile.txt`` in the directory you are standing in and below:
135+
!!! Exercise "Find the file ``myfile.txt`` in the directory you are standing in and below"
136+
137+
??? Solution "Click to reveal solution"
125138

126139
```bash
127140
find . -type f -name "file.txt"
128141
```
129142

130-
2. Find the files ``myfile.txt`` as part of the name in the directory ``expressions/patterns`` while standing in ``exercises/script``
143+
!!! Exercise "Find the files ``myfile.txt`` as part of the name in the directory ``expressions/patterns`` while standing in ``exercises/script``"
144+
145+
??? Solution "Click to reveal solution"
131146

132147
```bash
133148
find ../patterns/ -type f -name "myfile0.txt"
@@ -161,13 +176,17 @@ Some common examples of regular expressions:
161176
- **|** This wildcard makes a logical OR relationship between wildcards. You can thus search something or something else. You may need to add a '\' before this command to avoid the shell thinking you want a pipe.
162177
- **[^]** This is the equivalent of [!] in standard wildcards, i.e. it is a logical “not” and will match anything not listed within the square brackets.
163178

164-
!!! Example
179+
**Exercises**
180+
181+
!!! Exercise "Search the file myfile for lines starting with an "s" and ending with an "n", and prints them to the standard output"
182+
183+
??? Solution "Click to reveal solution"
165184

166185
```bash
167186
$ cat myfile | grep '^s.*n$'
168187
```
169188

170-
This command searches the file myfile for lines starting with an "s" and ending with an "n", and prints them to the standard output.
189+
171190

172191
!!! note "Keypoints"
173192

0 commit comments

Comments
 (0)