You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ee070e6
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
-
# Linux Command Line 101 - September 2025
1
+
# Linux Command Line 101 - 20 October 2025
2
2
3
3
## Course description
4
4
5
-
This course is given under <ahref="_https://www.naiss.se/"target="_blank">NAISS</a>, by staff working at the branches located at <ahref="https://www.uu.se/centrum/uppmax/"target="_blank">UPPMAX</a>, <ahref="https://www.lunarc.lu.se/"target="_blank">LUNARC</A>, and <ahref="https://www.hpc2n.umu.se/"target="_blank">HPC2N</a>.
5
+
This course is given under <ahref="_https://www.naiss.se/"target="_blank">NAISS</a>, by staff working at the branches located at <ahref="https://www.uu.se/centrum/uppmax/"target="_blank">UPPMAX</a>, <ahref="https://www.lunarc.lu.se/"target="_blank">LUNARC</A>, <ahref="https://www.hpc2n.umu.se/"target="_blank">HPC2N</a>, and <ahref="https://www.c3se.chalmers.se/"target="_blank">https://www.c3se.chalmers.se/</a>.
6
6
7
7
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.
8
8
9
9
It is meant for beginners to the Linux operating system.
10
10
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
12
12
13
13
Materials: Clone this repo or download a zip of the material (click the green "Code" button then pick "Download ZIP").
14
14
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
16
16
17
17
**Lecture recordings from the current course will be posted to HPC2N's YouTube page:**https://www.youtube.com/user/HPC2N
Copy file name to clipboardExpand all lines: docs/filesystem.md
+49-43Lines changed: 49 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,12 +21,11 @@ This section will be a basic overview of the Linux filesystem concepts, not an i
21
21
22
22
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>.
23
23
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.
25
25
26
26
!!! Note
27
27
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.
30
29
31
30
-**/** is the root of the directory structure on a Linux filesystem
32
31
-**/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
35
34
-**/usr/lib** holds kernel modules and shared library images needed to boot the system and run commands in the root filesystem
36
35
-**/usr/lib64** is the same as **/usr/lib**, just for 64-bit libraries
37
36
38
-
User-installed binaries are often located in **/opt**.
37
+
Userinstalled binaries are often located in **/opt**.
39
38
40
39
The file system could also be illustrated like this:
41
40
42
41
{: style="width: 500px;float: left"}
43
42
44
43
!!! warning "Note"
45
44
46
-
The character ``/`` can be
45
+
The character `/` can be
47
46
48
47
1. the root directory, if it is at the front of a file or directory name
49
48
2. a separator if it appears inside a path.
50
49
51
50
!!! note
52
51
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`).
54
53
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!
56
57
57
58
### Home folders on Tetralith
58
59
@@ -63,23 +64,23 @@ The above shows an illustration where the home folders are emphasized.
63
64
64
65
## Your home directory
65
66
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`.
67
68
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:
69
70
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`
75
76
76
77
!!! note
77
78
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!
79
80
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`.
81
82
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.
83
84
84
85
## pwd
85
86
@@ -119,7 +120,7 @@ You can use this to find out which directory you are in.
119
120
[bbrydsoe@cosmos1 ~]$
120
121
```
121
122
122
-
### Example, in a directory named ``testdir``
123
+
### Example, in a directory named `testdir`
123
124
124
125
On Tetralith, user ``x_birbr``:
125
126
@@ -129,7 +130,7 @@ On Tetralith, user ``x_birbr``:
129
130
[x_birbr@tetralith3 testdir]$
130
131
```
131
132
132
-
### Example, in subdirectory ``mydir`` under directory ``testdir``
133
+
### Example, in subdirectory `mydir` under directory `testdir`
133
134
134
135
On Tetralith, user ``x_birbr``:
135
136
@@ -141,7 +142,7 @@ On Tetralith, user ``x_birbr``:
141
142
142
143
## ls - listing files/directories
143
144
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.
145
146
146
147
<div>
147
148
```bash
@@ -260,35 +261,40 @@ Wild cards are also called "glob" or "globbing" patterns.
260
261
261
262
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.
262
263
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`.
264
265
265
266
<br>
266
267
267
268
**Common wildcards**
268
269
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.
275
276
276
277
!!! Warning
277
278
278
279
You may need quotation marks around some wildcards as well.
279
280
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
+
280
287
!!! tip "Try some of the commands below"
281
288
282
289
Useful files for these examples are found in ``exercises/patterns``
283
290
284
-
285
291
!!! Example "Some examples of the use of wildcards"
286
292
287
293
```bash
288
294
myfile?.txt
289
295
```
290
296
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``.
292
298
293
299
```bash
294
300
r*d
@@ -306,34 +312,34 @@ Wild cards are also called "glob" or "globbing" patterns.
306
312
a[d-j]a
307
313
```
308
314
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``.
310
316
311
317
```bash
312
318
[0-9]
313
319
```
314
320
315
-
This matches a range of numbers from 0 to 9.
321
+
This matches a range of numbers from 0 through 9.
316
322
317
323
```bash
318
324
cp {*.dat,*.c,*.pdf} ~
319
325
```
320
326
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.
322
328
323
329
```bash
324
330
rm thisfile[!8]*
325
331
```
326
332
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.
328
334
329
335
## cd - changing directory
330
336
331
-
The command ``cd`` is used to change directory.
337
+
The command `cd` is used to change directory.
332
338
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
337
343
338
344
!!! example
339
345
@@ -342,16 +348,16 @@ The command ``cd`` is used to change directory.
342
348
{: style="width: 500px;float: left"}
343
349
<br><br style="clear: both;">
344
350
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.
346
352
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.
348
354
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
350
356
```bash
351
357
cd exercises
352
358
```
353
359
354
-
To then change to the directory ``testdir1`` you do
360
+
To then change to the directory `testdir1` you do
355
361
```bash
356
362
cd testdir1
357
363
```
@@ -379,7 +385,7 @@ The command ``cd`` is used to change directory.
379
385
380
386
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.
381
387
382
-
!!! note "Keypoints"
388
+
!!! summary
383
389
384
390
- Your home directory is generally located in ``/home/USERNAME`` or ``/home/U/USERNAME``
385
391
- Your home directory is also stored as the environment variable ``$HOME``
Copy file name to clipboardExpand all lines: docs/patterns.md
+27-8Lines changed: 27 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,9 @@ See ``man grep`` for more options.
52
52
53
53
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.
54
54
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
+
55
58
!!! Example "Find the pattern 'word' in FILE"
56
59
57
60
```bash
@@ -64,6 +67,8 @@ See ``man grep`` for more options.
64
67
grep -rine 'word' path/to/dir
65
68
```
66
69
70
+
**Exercises**
71
+
67
72
!!! Exercise "Try finding the pattern ``string`` in ``newfile.txt``"
68
73
69
74
This file is also located in the ``exercises/patterns`` directory.
@@ -72,19 +77,25 @@ See ``man grep`` for more options.
You could do the searches inside ``exercises`` directory or inside ``exercises/patterns`` directory.
123
134
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"
125
138
126
139
```bash
127
140
find . -type f -name "file.txt"
128
141
```
129
142
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"
131
146
132
147
```bash
133
148
find ../patterns/ -type f -name "myfile0.txt"
@@ -161,13 +176,17 @@ Some common examples of regular expressions:
161
176
-**|** 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.
162
177
-**[^]** 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.
163
178
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"
165
184
166
185
```bash
167
186
$ cat myfile | grep '^s.*n$'
168
187
```
169
188
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.
0 commit comments