- Richard Feynman -
ITIC:Working in the shell - Introduction to Bash - Exercises
TODO: Write exercises before October 9 2019 (at the very latest).
There are exercises linked below to other parts of this wiki, as a backup (if we don't have time to write new ones) and also as a bonus for the ambitious students, if we do have time to write new ones.
- 1 Exercises
- 1.1 Basics
- 1.2 File system navigation
- 1.3 Issuing commands
- 1.4 Working with text files
- 1.5 Combining commands with pipes
- 1.6 Editing the commands line and some other tricks
- 1.7 Exit status
- 1.8 Blobbing and expansion
- 1.9 Introduction to shell expansion
- 1.10 Network
- 1.11 Swedish exercises
- 1.12 Bonus exercises
- 2 Links
A shell is a program that can be run interactively, e.g. in a terminal (or terminal emulator). Describe the terms (use a search engine, our Swedish compendium or the previous page if you need help):
- command line
- command line interface
Start a new terminal. Use
pwd to notice where you are in the file system. What is this directory called in general terms?
Issue the following command:
$ echo ~
Notice the output from echo. It seems that Bash has expanded the
~ to a path. What path is that?
Change directory to one of the directories that are in your current directory. You use
cd to change directory. But what do you need to write after the
cd command (as an argument) for it to know what to do?
What happens if you, from any directory, simply issues the command
cd without any arguments? Try it.
Change directory again, from your home directory to some other directory. Issue the command
pwd. Then issue the command
cd - (that is,
cd with the argument of a single dash
-). Where did you end up? Issue
cd - again. Where did you end up this time? Do it again, and again, until you figure it out.
In your home directory, issue the command
tree without arguments. What does it list? Next, issue the command
pwd again, but give it an argument of one of the directories in your current directory (e.g. Documents, Desktop, Music, Downloads etc - try all of them or if you don't have any of them, use an existing directory as the argument).
In your home directory, use
ls with the appropriate flag (or flags) to list all files and directories in a way that shows you which ones are files, and which ones are directories.
Next, issue the command
ls (without any arguments) and notice what files and directories are listed. Next, issue the command
ls -a and notice what additional files and directories are listed. The additional files and folders you see, look at their names and make a note of what they have in common.
Next, create a directory (you may use
mkdir to do this) called
.this-is-a-test (note the leading dot in the file name). Run
ls without arguments. Is the new directory listed? Use
ls -a to list all files again. Was the new directory listed?
rmdir to delete the new directory.
Working with text files
Commands: wc, grep,
Combining commands with pipes
Editing the commands line and some other tricks
Blobbing and expansion
Introduction to shell expansion
Variables: $ ? PATH HOME LANG USER
We will add exercises here when we have the time. See below for now.
Here are links to our Swedish compendium (which contains a lot of Bash), and the companion Swedish exercise PDF (which has a lot of Bash exercises).
- Datorkunskap för IT-studenter.pdf (102 pages)
These are some recommended exercise pages from other parts of this wiki:
- Bash - intro - Exercises
- Bash - Files and folders - Exercises
- Bash - Directory structure - exercises
- Bash - Text files - exercises
- Bash - Standard streams - Exercises
- Bash - Redirecting streams - Exercises
Where to go next
The next page is Networks_and_protocols.