diff --git a/exercises/UNIX_HPX_exercise_instructions.md b/exercises/UNIX_HPX_exercise_instructions.md index 605121b40bca61d6fe3f64dce4cd09b4fe9d9cf5..4f2e92ac47e4aa769cff2a93c2817c60b125ed2d 100644 --- a/exercises/UNIX_HPX_exercise_instructions.md +++ b/exercises/UNIX_HPX_exercise_instructions.md @@ -1,4 +1,4 @@ -##Exercise 1 - Navigating the filesystem on command line +## Exercise 1 - Navigating the filesystem on command line **Objective:** get familiar with navigating the directory tree and listing the content of directories. @@ -22,3 +22,66 @@ the content of directories. same as `ls -l -h -a`. * *Note:* some options have both a "short" and a "long" form. E.g. `ls -a` is the short form for `ls --all`. + + +<br> +<details><summary><b>Exercise solution</b></summary> +<p> + +1. Printing the current working directory: + + ```sh + pwd + ``` + +2. Navigate to the current directory, or navigate in and out of it. + + ```sh + # If you are not already in the practicals directory. + # Note: in the command below, you need to replace /path/to/directory/ with + # the actual absolute or relative path of the directory where your + # "practicals" directory is located. + cd /path/to/directory/exercises + pwd + + # If you are already in the practicals directory. + cd .. # Change to parent directory. + pwd # + ls -l # + cd exercises/ # Go back into the practicals/ directory. + ``` + +3. The `.` symbol is a shortcut for the current directory. So running `cd .` + has no effect since it simply changes to the same directory we are already + in. + + The `.` shortcut is useful in some situations. E.g. if you want to copy + a file to the current directory you can do `cp /file/to/copy .`, or you + can run an executable located in the current directory with `./run_me.sh`. + + +4. Listing the content of the `exercises/` directory with different `ls` + options. the effect of the different options is described in the comments + of the code block below. + + ```sh + ls # Prints the names of files and directories + ls -l # List content of the subdirectory in "long listing" format. This + # provides additional details for each file/directory, such as + # its permissions, its size and its last modified date. + ls -lh # Adding the "-h" option displays file sizes in "human readable" + # format. The size of files are shown in kB, MB, GB, instead of + # their size in bytes (octets). + ls -lha # Adding the "-a" option additionally displays hidden files and + # directories. These are files/directories whose name starts with + # a dot ".". The "-a" is the + # Hidden files are often used to store program configurations. + ``` + + **Tip:** It is possible to define a shorthand for longer commands that you use often, a so called `alias`. On Science Cluster, there are already some pre-defined useful aliases, among them `ll` (standing for `ls -lFh`) and `la` (standing for `ls -lA`). + + + +</p> +</details> +<br> \ No newline at end of file