1- Getting Started
2- ===============
3-
4- Logging in
5- ----------
1+ # Getting Started
62
73To get started with the HPC-UGent infrastructure, you need to obtain a
8- VSC account, see [ HPC manual] ( ../account.md ) .
9- ** Keep in mind that you must keep your private key to yourself!**
10-
11- You can look at your public/private key pair as a lock and a key: you
12- give us the lock (your public key), we put it on the door, and then you
13- can use your key to open the door and get access to the HPC
14- infrastructure. ** Anyone who has your key can use your VSC account!**
15-
4+ VSC account, see [ HPC manual] ( ../account.md ) .
165Details on connecting to the HPC infrastructure are available in
176[ HPC manual connecting section] ( ../connecting.md ) .
187
19- Getting help
20- ------------
8+ ## Getting help
219
2210To get help:
2311
@@ -42,8 +30,7 @@ carefully and try to act on it. Try googling the error first to find any
4230possible solution, but if you can't come up with something in 15
4331minutes, don't hesitate to mail <a href="mailto:{{hpcinfo}}">{{hpcinfo}}</a>.
4432
45- Basic terminal usage
46- --------------------
33+ ## Basic terminal usage
4734
4835The basic interface is the so-called shell prompt, typically ending with
4936`$` (for `bash` shells).
@@ -77,11 +64,11 @@ If for any reason you want to stop a command from executing, press
7764`Ctrl-C`. For example, if a command is taking too long, or you want to
7865rerun it with different arguments.
7966
80- Variables
81- ---------
67+ ## Variables
68+
8269[//]: # (sec:environment-variables())
8370
84- At the prompt we also have access to shell variables, which have both a
71+ At the prompt we also have access to * shell variables* , which have both a
8572*name* and a *value*.
8673
8774They can be thought of as placeholders for things we need to remember.
@@ -95,8 +82,6 @@ shell variable named `HOME`:
9582
9683This prints the value of this variable.
9784
98- ### Defining variables
99-
10085There are several variables already defined for you when you start your
10186session, such as `$HOME` which contains the path to your home directory.
10287
@@ -110,19 +95,27 @@ HOME=/user/home/gent/vsc400/vsc40000
11095...
11196</code></pre>
11297
98+ !!! info
99+ In Linux, the pipe operator (`|`) is used to pass output from one command as input to another.
100+ This is known as a pipeline. Here, `env | sort` will take the output of `env` and use it as the input for `sort`.
101+ This can be extremely useful for chaining together commands and processing data.
102+
113103You can also use the `grep` command to search for a piece of text. The
114104following command will output all VSC-specific variable names and their
115105values:
116106
117107<pre><code>$ <b>env | sort | grep VSC</b></code></pre>
118108
119- But we can also define our own. this is done with the `export` command
120- (note: variables are always all-caps as a convention):
109+ ### Defining variables
110+
111+ It is also possible to define your own variables. this is done with the `export` command:
121112
122113<pre><code>$ <b>export MYVARIABLE="value"</b></code></pre>
123114
124- It is important you don't include spaces around the `=` sign. Also note
125- the lack of `$` sign in front of the variable name.
115+
116+ !!! note
117+ Notice the lack of the `$` sign and spaces around the `=` sign.
118+ By convention, variables should be all-caps.
126119
127120If we then do
128121<pre><code>$ <b>echo $MYVARIABLE</b></code></pre>
@@ -131,56 +124,11 @@ this will output `value`. Note that the quotes are not included, they
131124were only used when defining the variable to escape potential spaces in
132125the value.
133126
134- #### Changing your prompt using `$PS1`
135-
136- You can change what your prompt looks like by redefining the
137- special-purpose variable `$PS1`.
138-
139- For example: to include the current location in your prompt:
140- <pre><code>$ <b>export PS1='\w $'</b>
141- ~ $ cd test
142- ~/test $
143- </code></pre>
144-
145- Note that `~` is short representation of your home directory.
146-
147- To make this persistent across session, you can define this custom value
148- for `$PS1` in your `.profile` startup script:
149- <pre><code>$ <b>echo 'export PS1="\w $ " ' >> ~/.profile</b></code></pre>
150-
151- ### Using non-defined variables
152-
153- One common pitfall is the (accidental) use of non-defined variables.
154- Contrary to what you may expect, this does *not* result in error
155- messages, but the variable is considered to be *empty* instead.
156-
157- This may lead to surprising results, for example:
158- <pre><code>$ <b>export WORKDIR=/tmp/test</b>
159- $ <b>pwd</b>
160- /user/home/gent/vsc400/vsc40000
161- $ <b>echo $HOME</b>
162- /user/home/gent/vsc400/vsc40000
163- </code></pre>
164-
165- To understand what's going on here, see the section on `cd` below.
166-
167- The moral here is: **be very careful to not use empty variables unintentionally**.
168-
169- **Tip for job scripts: use `set -e -u` to avoid using empty variables accidentally.**
170-
171- The `-e` option will result in the script getting stopped if any command
172- fails.
173-
174- The `-u` option will result in the script getting stopped if empty
175- variables are used. (see <https://ss64.com/bash/set.html> for a more
176- detailed explanation and more options)
177-
178- More information can be found at <http://www.tldp.org/LDP/abs/html/variables.html>.
179127
180128### Restoring your default environment
181129
182130If you've made a mess of your environment, you shouldn't waste too much
183- time trying to fix it. Just log out and log in again and you will be
131+ time trying to fix it. Just log out and log in again, and you will be
184132given a pristine environment.
185133
186134Basic system information
@@ -205,20 +153,49 @@ Linux gligar01.gligar.os 2.6.32-573.8.1.el6.ug.x86_64 #1 SMP Mon Nov 16 15:12:09
205153
206154
207155
208- Exercises
209- ---------
156+ ## Exercises
210157
211- - Print the full path to your home directory
158+ ??? abstract "Print the full path to your home directory"
159+ ```bash
160+ $ echo $HOME
161+ ```
212162
213- - Determine the name of the environment variable to your personal
214- scratch directory
163+ ??? abstract "Determine the name of the environment variable to your personal scratch directory"
164+ ```bash
165+ $ env | grep SCRATCH
166+ ```
215167
216- - What's the name of the system you're logged into? Is it the same for
217- everyone?
168+ ??? abstract "What's the name of the system you're logged into? Is it the same for everyone?"
169+ ```bash
170+ $ hostname
171+ ```
172+
173+ Not everyone will be logged in to the same node, so the output will differ.
174+
175+ ??? abstract "Figure out how to print the value of a variable without including a newline"
176+
177+ We can use the `man` command to find relevant information on the echo command with:
218178
219- - Figure out how to print the value of a variable without including a
220- newline
179+ ```bash
180+ $ man echo
181+ ```
221182
222- - How do you get help on using the `man` command?
183+ We find the following line in the manual:
184+
185+ ```
186+ -n do not output the trailing newline
187+ ```
188+
189+ So we can use the `-n` flag to suppress the newline:
190+
191+ ```bash
192+ $ echo -n $HOME
193+ ```
194+
195+ ??? abstract "How do you get help on using the `man` command?"
196+
197+ ```bash
198+ $ man man
199+ ```
223200
224- Next [chapter](navigating.md) teaches you on how to navigate.
201+ Next [chapter](navigating.md) teaches you how to navigate the filesystem .
0 commit comments