This tutorial makes you familiar with bash, the Linux command line. You will learn to:
- navigate directories
- manipulate files
- execute programs
If you have no previous experience with Unix-like systems or know a few commands but would like to know more, this tutorial is for you.
This tutorial was prepared for Ubuntu Linux, but it works on MacOS, Cygwin and the Git bash as well, given that Python 3 is installed on your system.
In this tutorial, you will be looking for a word with 22 characters:
All characters are hidden in the exercises below.
- clone the repository or download the code as a ZIP file
- locate the
exercises/
folder - open a
bash
terminal
The first character is hidden in a file somewhere in the exercise1 directory tree. Look through subdirectories until you find one with the name solution_1.1
and list its contents.
1.2. Show a hidden file
Some files are not visible immediately. The second character, is in the same directory as the first one, but in a hidden file.
Go back to the directory exercise_1/directoryB/
. When listing its contents, you should see a shell script file program.sh
. To find the third character, you need to execute the program.
Go to the folder exercise_1/directoryC/
. To find the fourth character, you need to find out how big the text file in the directory is.
To obtain the fourth character look up the file size in the Table of printable ASCII characters:
ASCII Table, Public Domain
Please go back to the top directory of the tutorial material. Then, change to the directory exercise_2
.
In the directory exercise_2/, you will find a text file solution_2.1.txt. The fifth character is inside that file.
To get character number six, you will need to create a text file in the exercise_2
directory. On Ubuntu, you can do this using the editor nano
.
To exit nano, type Ctrl-X
Create a text file with the characters you have found so far.
The sixth character is the one you need to press to save a file in
nano
.
Please go to the directory exercise_3.
To find characters seven and eight, you need to create a subdirectory named solution in exercise_3/
and copy the files from the part1/
and part2/
folders into it. Then, look at the files in the soltion folder.
In the data
directory, all files with an Y
need to be deleted. Use Wildcards to delete the files. To get characters nine and ten, look at the files that remain after deleting all that contain a Y
.
Please go to the directory exercise_4.
There are two different versions of a quote, ai.txt
, and artificial_intelligence.txt
. The 11th character of the solution is the single character in which the
two files differ. Do not do this manually but use a command.
The 12th character of the solution is the first character of the last word in the file elephant.txt when all lines are sorted alphabetically.
To find the 13th character, search for the word fire in the file datascience.txt
and take the first character of the output. Do not do this manually but use a command.
Please go to the directory exercise_5.
The 14th and 15th character of the solution are in a multiply wrapped archive in the exercise_5 directory.
Please go to the directory exercise_6
.
To see characters 16+17 of the solution, make the program permissions.sh
executable. Then execute it.
To obtain the 18th character, check out the version of the Unix utility program to find out empty disk space.
The solution is the last character of the programs first authors' first name.
To install some programs, it is necessary to set so-called environment variables.
To obtain the 19th character, you need to set the variable GIVEME to the value SOLUTION.
Find out the characters position in the alphabet by getting the number of bytes in the value of the GIVEME variable.
The 20th character is the ping
option that sets the maximum number of requests sent. Check the documentation in the manpages.
Use the Linux equivalent of the Windows Task Manager to display currently running programs.
The last two characters of the solution are the first two characters of the second word in the line containing the column labels.
© 2024 Dr. Kristian Rother
This tutorial is published under the Creative Commons Attribution Share-alike License 4.0
You can find the full sources on https://github.com/krother/bash_tutorial.
Thanks to many students for using the tutorial in practice and finding bugs. Thanks to @zulcas
for contributing bugfixes.
I thank Janusz M. Bujnicki, Allegra Via, Pedro Fernandes and Joachim Jacob for their help with testing and reviewing the material. Further thanks go to the German Academic Exchange Service (DAAD) for financial support.