diff --git a/mkdocs/docs/HPC/linux-tutorial/getting_started.md b/mkdocs/docs/HPC/linux-tutorial/getting_started.md index 735194999c1..1a9a20aeeac 100644 --- a/mkdocs/docs/HPC/linux-tutorial/getting_started.md +++ b/mkdocs/docs/HPC/linux-tutorial/getting_started.md @@ -1,37 +1,33 @@ -Getting Started -=============== +# Getting Started -Logging in ----------- +## Logging in To get started with the HPC-UGent infrastructure, you need to obtain a -VSC account, see [HPC manual](../account.md). -**Keep in mind that you must keep your private key to yourself!** +VSC account, see [HPC manual](../account.md). **Keep in mind that you +must keep your private key to yourself!** You can look at your public/private key pair as a lock and a key: you give us the lock (your public key), we put it on the door, and then you can use your key to open the door and get access to the HPC infrastructure. **Anyone who has your key can use your VSC account!** -Details on connecting to the HPC infrastructure are available in -[HPC manual connecting section](../connecting.md). +Details on connecting to the HPC infrastructure are available in [HPC +manual connecting section](../connecting.md). -Getting help ------------- +## Getting help To get help: -1. use the documentation available on the system, through the `help`, - `info` and `man` commands (use `q` to exit). +1. use the documentation available on the system, through the + `help`, `info` and `man` commands (use `q` to exit). + ``` + help cd + info ls + man cp ``` - help cd - info ls - man cp - ``` - 2. use Google -3. contact {{hpcinfo}} in case +3. contact {{hpcinfo}} in case of problems or questions (even for basic things!) ### Errors @@ -40,30 +36,30 @@ Sometimes when executing a command, an error occurs. Most likely there will be error output or a message explaining you this. Read this carefully and try to act on it. Try googling the error first to find any possible solution, but if you can't come up with something in 15 -minutes, don't hesitate to mail {{hpcinfo}}. +minutes, don't hesitate to mail +{{hpcinfo}}. -Basic terminal usage --------------------- +## Basic terminal usage The basic interface is the so-called shell prompt, typically ending with `$` (for `bash` shells). -You use the shell by executing commands, and hitting ``. For -example: -
$ echo hello
-hello
-
+You use the shell by executing commands, and hitting +``. For example: +
$ echo hello 
+ hello 
-You can go to the start or end of the command line using `Ctrl-A` or -`Ctrl-E`. +You can go to the start or end of the command line using +`Ctrl-A` or `Ctrl-E`. -To go through previous commands, use `` and ``, rather than -retyping them. +To go through previous commands, use `` and +``, rather than retyping them. ### Command history A powerful feature is that you can "search" through your command -history, either using the `history` command, or using `Ctrl-R`: +history, either using the `history` command, or using +`Ctrl-R`:
$ history
     1 echo hello
 
@@ -74,11 +70,11 @@ history, either using the `history` command, or using `Ctrl-R`:
 ### Stopping commands
 
 If for any reason you want to stop a command from executing, press
-`Ctrl-C`. For example, if a command is taking too long, or you want to
-rerun it with different arguments.
+`Ctrl-C`. For example, if a command is taking too long, or
+you want to rerun it with different arguments.
+
+## Variables
 
-Variables
----------
 [//]: # (sec:environment-variables())
 
 At the prompt we also have access to shell variables, which have both a
@@ -89,7 +85,7 @@ They can be thought of as placeholders for things we need to remember.
 For example, to print the path to your home directory, we can use the
 shell variable named `HOME`:
 
-
$ echo $HOME
+
$ echo $HOME 
 /user/home/gent/vsc400/vsc40000
 
@@ -98,38 +94,40 @@ This prints the value of this variable. ### Defining variables There are several variables already defined for you when you start your -session, such as `$HOME` which contains the path to your home directory. +session, such as `$HOME` which contains the path to your +home directory. For a full overview of defined environment variables in your current -session, you can use the `env` command. You can sort this output with -`sort` to make it easier to search in: +session, you can use the `env` command. You can sort this +output with `sort` to make it easier to search in: -
$ env | sort
-...
-HOME=/user/home/gent/vsc400/vsc40000
+
$ env | sort 
 ...
-
+HOME=/user/home/gent/vsc400/vsc40000 +...
-You can also use the `grep` command to search for a piece of text. The -following command will output all VSC-specific variable names and their -values: +You can also use the `grep` command to search for a piece of +text. The following command will output all VSC-specific variable names +and their values:
$ env | sort | grep VSC
-But we can also define our own. this is done with the `export` command -(note: variables are always all-caps as a convention): +But we can also define our own. this is done with the +`export` command (note: variables are always all-caps as a +convention):
$ export MYVARIABLE="value"
-It is important you don't include spaces around the `=` sign. Also note -the lack of `$` sign in front of the variable name. +It is important you don't include spaces around the `=` +sign. Also note the lack of `$` sign in front of the +variable name. -If we then do +If we then do
$ echo $MYVARIABLE
-this will output `value`. Note that the quotes are not included, they -were only used when defining the variable to escape potential spaces in -the value. +this will output `value`. Note that the quotes are not +included, they were only used when defining the variable to escape +potential spaces in the value. #### Changing your prompt using `$PS1` @@ -138,11 +136,11 @@ special-purpose variable `$PS1`. For example: to include the current location in your prompt:
$ export PS1='\w $'
-~ $ cd test
-~/test $
-
+~ $ cd test +~/test $
-Note that `~` is short representation of your home directory. +Note that `~` is short representation of your home +directory. To make this persistent across session, you can define this custom value for `$PS1` in your `.profile` startup script: @@ -154,71 +152,61 @@ One common pitfall is the (accidental) use of non-defined variables. Contrary to what you may expect, this does *not* result in error messages, but the variable is considered to be *empty* instead. -This may lead to surprising results, for example: -
$ export WORKDIR=/tmp/test
+This may lead to surprising results, for example: 
+
$ export WORKDIR=/tmp/test 
 $ pwd
-/user/home/gent/vsc400/vsc40000
+/user/home/gent/vsc400/vsc40000 
 $ echo $HOME
-/user/home/gent/vsc400/vsc40000
-
+/user/home/gent/vsc400/vsc40000
To understand what's going on here, see the section on `cd` below. -The moral here is: **be very careful to not use empty variables unintentionally**. +The moral here is: **be very careful to not use empty variables +unintentionally**. -**Tip for job scripts: use `set -e -u` to avoid using empty variables accidentally.** +**Tip for job scripts: use `set -e -u` to avoid using empty variables +accidentally.** -The `-e` option will result in the script getting stopped if any command -fails. +The `-e` option will result in the script getting stopped if +any command fails. -The `-u` option will result in the script getting stopped if empty -variables are used. (see for a more -detailed explanation and more options) +The `-u` option will result in the script getting stopped if +empty variables are used. (see for +a more detailed explanation and more options) -More information can be found at . +More information can be found at +. ### Restoring your default environment -If you've made a mess of your environment, you shouldn't waste too much -time trying to fix it. Just log out and log in again and you will be -given a pristine environment. +If you've made a mess of your environment, you shouldn't waste too +much time trying to fix it. Just log out and log in again and you will +be given a pristine environment. -Basic system information ------------------------- +## Basic system information Basic information about the system you are logged into can be obtained in a variety of ways. -We limit ourselves to determining the hostname: -
$ hostname
+We limit ourselves to determining the hostname: 
+
$ hostname 
 gligar01.gligar.os
 
-$ echo $HOSTNAME
-gligar01.gligar.os
+$ echo $HOSTNAME 
+gligar01.gligar.os 
 
And querying some basic information about the Linux kernel: -
$ uname -a
+
$ uname -a 
 Linux gligar01.gligar.os 2.6.32-573.8.1.el6.ug.x86_64 #1 SMP Mon Nov 16 15:12:09
-    CET 2015 x86_64 x86_64 x86_64 GNU/Linux
-
- - - -Exercises ---------- - -- Print the full path to your home directory - -- Determine the name of the environment variable to your personal - scratch directory - -- What's the name of the system you're logged into? Is it the same for - everyone? + CET 2015 x86_64 x86_64 x86_64 GNU/Linux
-- Figure out how to print the value of a variable without including a - newline +## Exercises -- How do you get help on using the `man` command? +- Print the full path to your home directory +- Determine the name of the environment variable to your personal scratch directory +- What's the name of the system you\'re logged into? Is it the same for everyone? +- Figure out how to print the value of a variable without including a newline +- How do you get help on using the `man` command? Next [chapter](navigating.md) teaches you on how to navigate. diff --git a/mkdocs/docs/HPC/linux-tutorial/navigating.md b/mkdocs/docs/HPC/linux-tutorial/navigating.md index bd882acafbb..030f7b5da54 100644 --- a/mkdocs/docs/HPC/linux-tutorial/navigating.md +++ b/mkdocs/docs/HPC/linux-tutorial/navigating.md @@ -1,210 +1,195 @@ -Navigating -========== +# Navigating -This chapter serves as a guide to navigating within a Linux shell, giving users essential techniques to traverse directories. -A very important skill. +This chapter serves as a guide to navigating within a Linux shell, +giving users essential techniques to traverse directories. A very +important skill. -Current directory: "pwd" and "\$PWD" ------------------------------------- +## Current directory: "pwd" and "$PWD" -To print the current directory, use `pwd` or `$PWD`: -
$ cd $HOME
+To print the current directory, use `pwd` or `\$PWD`:
+
$ cd $HOME 
 $ pwd
-/user/home/gent/vsc400/vsc40000
-$ echo "The current directory is: $PWD"
+/user/home/gent/vsc400/vsc40000 
+$ echo "The current directory is: $PWD" 
 The current directory is: /user/home/gent/vsc400/vsc40000
 
-Listing files and directories: "ls" ------------------------------------ +## Listing files and directories: "ls" -A very basic and commonly used command is `ls`, which can be used to -list files and directories. +A very basic and commonly used command is `ls`, which can be +used to list files and directories. -In its basic usage, it just prints the names of files and directories -in the current directory. For example: -
$ ls
-afile.txt some_directory
-
+In its basic usage, it just prints the names of files and directories in +the current directory. For example:
$ ls
+afile.txt some_directory 
When provided an argument, it can be used to list the contents of a -directory: -
$ ls some_directory
-one.txt two.txt
-
- +directory:
$ ls some_directory 
+one.txt two.txt 
A couple of commonly used options include: -- detailed listing using `ls -l`: -
$ ls -l
-total 4224
--rw-rw-r-- 1 vsc40000 vsc40000 2157404 Apr 12 13:17 afile.txt
-drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
- -- To print the size information in human-readable form, use the `-h` - flag: -
$ ls -lh
-total 4.1M
--rw-rw-r-- 1 vsc40000 vsc40000 2.1M Apr 12 13:16 afile.txt
-drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
- -- also listing hidden files using the `-a` flag: - -
$ ls -lah
-total 3.9M
-drwxrwxr-x 3 vsc40000 vsc40000 512 Apr 12 13:11 .
-drwx------ 188 vsc40000 vsc40000 128K Apr 12 12:41 ..
--rw-rw-r-- 1 vsc40000 vsc40000 1.8M Apr 12 13:12 afile.txt
--rw-rw-r-- 1 vsc40000 vsc40000 0 Apr 12 13:11 .hidden_file.txt
-drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
- -- ordering files by the most recent change using `-rt`: - -
$ ls -lrth
-total 4.0M
-drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
--rw-rw-r-- 1 vsc40000 vsc40000 2.0M Apr 12 13:15 afile.txt
- -If you try to use `ls` on a file that doesn't exist, you will get a -clear error message: -
$ ls nosuchfile
+- detailed listing using `ls -l`:
+
+:   
$ ls -l
+	total 4224 
+	-rw-rw-r-- 1 vsc40000 vsc40000 2157404 Apr 12 13:17 afile.txt 
+	drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
+ +- To print the size information in human-readable form, use the `-h` flag: + +:
$ ls -lh
+	total 4.1M 
+	-rw-rw-r-- 1 vsc40000 vsc40000 2.1M Apr 12 13:16 afile.txt
+	drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
+ +- also listing hidden files using the `-a` flag: + +:
$ ls -lah
+	total 3.9M 
+	drwxrwxr-x 3 vsc40000 vsc40000 512 Apr 12 13:11 .
+	drwx------ 188 vsc40000 vsc40000 128K Apr 12 12:41 .. 
+	-rw-rw-r-- 1 vsc40000 vsc40000 1.8M Apr 12 13:12 afile.txt 
+	-rw-rw-r-- 1 vsc40000 vsc40000 0 Apr 12 13:11 .hidden_file.txt 
+	drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory
+ +- ordering files by the most recent change using `-rt`: + +:
$ ls -lrth
+	total 4.0M 
+	drwxrwxr-x 2 vsc40000 vsc40000 512 Apr 12 12:51 some_directory 
+	-rw-rw-r-- 1 vsc40000 vsc40000 2.0M Apr 12 13:15 afile.txt
+ +If you try to use `ls` on a file that doesn't exist, you +will get a clear error message: +
$ ls nosuchfile 
 ls: cannot access nosuchfile: No such file or directory
 
-Changing directory: "cd" ------------------------- +## Changing directory: "cd" -To change to a different directory, you can use the `cd` command: +To change to a different directory, you can use the `cd` +command:
$ cd some_directory
+ To change back to the previous directory you were in, there's a shortcut: `cd -` -Using `cd` without an argument results in returning back to your home -directory: -
$ cd
+Using `cd` without an argument results in returning back to
+your home directory: 
+
$ cd 
 $ pwd
-/user/home/gent/vsc400/vsc40000
-
+/user/home/gent/vsc400/vsc40000
+## Inspecting file type: "file" -Inspecting file type: "file" ----------------------------- +The `file` command can be used to inspect what type of file +you're dealing with: -The `file` command can be used to inspect what type of file you're -dealing with:
$ file afile.txt
 afile.txt: ASCII text
 
-$ file some_directory
+$ file some_directory 
 some_directory: directory
 
-Absolute vs relative file paths -------------------------------- +## Absolute vs relative file paths -An *absolute* filepath starts with `/` (or a variable which value starts -with `/`), which is also called the *root* of the filesystem. +An *absolute* filepath starts with `/` (or a variable which +value starts with `/`), which is also called the *root* of +the filesystem. -Example: absolute path to your home directory: `/user/home/gent/vsc400/vsc40000`. +Example: absolute path to your home directory: +`/user/home/gent/vsc400/vsc40000`. A *relative* path starts from the current directory, and points to another location up or down the filesystem hierarchy. -Example: `some_directory/one.txt` points to the file `one.txt` that is -located in the subdirectory named `some_directory` of the current -directory. +Example: `some_directory/one.txt` points to the file +`one.txt` that is located in the subdirectory named +`some_directory` of the current directory. There are two special relative paths worth mentioning: - `.` is a shorthand for the current directory +- `..` is a shorthand for the parent of the current + directory -- `..` is a shorthand for the parent of the current directory +You can also use `..` when constructing relative paths, for +example: -You can also use `..` when constructing relative paths, for example: -
$ cd $HOME/some_directory
-$ ls ../afile.txt
-../afile.txt
-
+
$ cd $HOME/some_directory 
+$ ls ../afile.txt 
+../afile.txt 
-Permissions ------------ +## Permissions [//]: # (sec:permissions) Each file and directory has particular *permissions* set on it, which can be queried using `ls -l`. -For example: -
$ ls -l afile.txt
--rw-rw-r-- 1 vsc40000 agroup 2929176 Apr 12 13:29 afile.txt
-
- -The `-rwxrw-r--` specifies both the type of file (`-` for files, `d` for -directories (see first character)), and the permissions for -user/group/others: +For example: +
$ ls -l afile.txt 
+-rw-rw-r-- 1 vsc40000 agroup 2929176 Apr 12 13:29 afile.txt 
-1. each triple of characters indicates whether the read (`r`), write - (`w`), execute (`x`) permission bits are set or not +The `-rwxrw-r--` specifies both the type of file +(`-` for files, `d` for directories (see first +character)), and the permissions for user/group/others: -2. the 1st part `rwx` indicates that the *owner* "vsc40000" of the file has all - the rights - -3. the 2nd part `rw-` indicates the members of the *group* "agroup" - only have read/write permissions (not execute) - -4. the 3rd part `r--` indicates that *other* users only have read - permissions +1. each triple of characters indicates whether the read + (`r`), write (`w`), execute + (`x`) permission bits are set or not +2. the 1st part `rwx` indicates that the *owner* + "vsc40000" of the file has all the rights +3. the 2nd part `rw-` indicates the members of the *group* + "agroup" only have read/write permissions (not execute) +4. the 3rd part `r--` indicates that *other* users only + have read permissions The default permission settings for new files/directories are determined by the so-called *umask* setting, and are by default: 1. read-write permission on files for user/group (no execute), read-only for others (no write/execute) - 2. read-write-execute permission for directories on user/group, read/execute-only for others (no write) -See also [the chmod command](manipulating_files_and_directories.md#changing-permissions---chmod--sec--chmod) +See also [the chmod command](manipulating_files_and_directories.md#changing-permissions---chmod--sec--chmod) later in this manual. -Finding files/directories: "find" ---------------------------------- +## Finding files/directories: "find" -`find` will crawl a series of directories and lists files matching given -criteria. +`find` will crawl a series of directories and lists files +matching given criteria. -For example, to look for the file named `one.txt`: -
$ cd $HOME
+For example, to look for the file named `one.txt`: 
+
$ cd $HOME 
 $ find . -name one.txt
-./some_directory/one.txt
-
+./some_directory/one.txt
-To look for files using incomplete names, you can use a wildcard `*`; -note that you need to escape the `*` to avoid that Bash *expands* it -into `afile.txt` by adding double quotes: +To look for files using incomplete names, you can use a wildcard +`*`; note that you need to escape the `*` to +avoid that Bash *expands* it into `afile.txt` by adding +double quotes:
$ find . -name "*.txt"
-./.hidden_file.txt
-./afile.txt
+./.hidden_file.txt 
+./afile.txt 
 ./some_directory/one.txt
-./some_directory/two.txt
-
+./some_directory/two.txt
-A more advanced use of the `find` command is to use the `-exec` flag to -perform actions on the found file(s), rather than just printing their -paths (see `man find`). +A more advanced use of the `find` command is to use the +`-exec` flag to perform actions on the found file(s), rather +than just printing their paths (see `man find`). -Exercises ---------- - -- Go to `/tmp`, then back to your home directory. How many different - ways to do this can you come up with? +## Exercises +- Go to `/tmp`, then back to your home directory. How many + different ways to do this can you come up with? - When was your home directory created or last changed? - - Determine the name of the last changed file in `/tmp`. - - See how home directories are organised. Can you access the home directory of other users? -The [next](manipulating_files_and_directories.md) chapter will teach you how to interact with files and directories. +The [next](manipulating_files_and_directories.md) chapter will teach +you how to interact with files and directories.