Skip to content
Snippets Groups Projects
Commit a6b2737c authored by Fanny Wegner's avatar Fanny Wegner
Browse files

Merge branch 'master-patch-f641' into 'master'

edits to exercises

See merge request !3
parents 4f50cca6 88bdb88e
No related branches found
No related tags found
1 merge request!3edits to exercises
##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 **Objective:** get familiar with navigating the directory tree and listing
the content of directories. the content of directories.
...@@ -22,3 +22,66 @@ the content of directories. ...@@ -22,3 +22,66 @@ the content of directories.
same as `ls -l -h -a`. same as `ls -l -h -a`.
* *Note:* some options have both a "short" and a "long" form. E.g. `ls -a` * *Note:* some options have both a "short" and a "long" form. E.g. `ls -a`
is the short form for `ls --all`. 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment