Review exercises
Table of contentsβ
- Validation quiz
- Exercise 1: Navigation
- Exercise 2: File manipulation
- Mini-project: Organize a directory tree
- Next steps
1 - Validation quizβ
Test your knowledge of the Linux fundamentals.
Questionsβ
Q1. Which command displays the current directory?
See the answer
pwd (Print Working Directory)
Q2. How do you create a folder with all its parents if they don't exist?
See the answer
mkdir -p chemin/vers/dossier
The -p (parents) option creates all the intermediate directories.
Q3. What is the difference between rm and rmdir?
See the answer
rmdir: deletes only empty directoriesrm: deletes files, and with-r, directories (even non-empty ones)
Q4. How do you display the last 15 lines of a file?
See the answer
tail -n 15 fichier.txt or tail -15 fichier.txt
Q5. What does the ~ symbol mean in a path?
See the answer
The home directory of the current user.
Example: ~ = /home/username
Q6. How do you copy a directory with all its content?
See the answer
cp -r source/ destination/
The -r (recursive) option copies the content recursively.
Q7. Which command searches for "error" in all .log files?
See the answer
grep "error" *.log
With the -i option to ignore case: grep -i "error" *.log
Q8. How do you follow a log file in real time?
See the answer
tail -f /chemin/vers/fichier.log
The -f (follow) option displays new lines as they come.
Q9. In vim, how do you save and quit?
See the answer
- Press
Escto be in normal mode - Type
:wqthenEnter
Or simply ZZ (uppercase) in normal mode.
Q10. What does the * wildcard do?
See the answer
It represents any characters (0 or more).
Example: *.txt = all files ending with .txt
Resultsβ
| Score | Level |
|---|---|
| 10/10 | Excellent! You are ready for Linux 2 |
| 7-9/10 | Good! Review the points you missed |
| 4-6/10 | Average. Reread the relevant chapters |
| 0-3/10 | Start the course over from the beginning |
π Back to table of contentsβ
2 - Exercise 1: Navigationβ
Goalβ
Navigate the Linux directory tree and explore the system.
Instructionsβ
Run the following commands and note the results:
# 1. Affichez votre rΓ©pertoire courant
pwd
# 2. Allez à la racine du système
cd /
# 3. Listez le contenu de la racine
ls -la
# 4. Allez dans /var/log
cd /var/log
# 5. Listez les fichiers par date (rΓ©cent en premier)
ls -lt
# 6. Revenez Γ votre home
cd ~
# 7. CrΓ©ez un dossier de travail
mkdir exercices_linux
# 8. Entrez dedans
cd exercices_linux
# 9. VΓ©rifiez oΓΉ vous Γͺtes
pwd
Questionsβ
- How many directories are there at the root
/? - What is the most recent file in
/var/log? - What is the full path of your
exercices_linuxfolder?
π Back to table of contentsβ
3 - Exercise 2: File manipulationβ
Goalβ
Create, copy, move, and delete files and folders.
Instructionsβ
# Assurez-vous d'Γͺtre dans ~/exercices_linux
cd ~/exercices_linux
# 1. CrΓ©ez cette structure :
# exercices_linux/
# βββ documents/
# βββ images/
# βββ scripts/
# βββ temp/
mkdir documents images scripts temp
# 2. CrΓ©ez des fichiers de test
touch documents/rapport.txt documents/notes.txt
touch images/photo1.jpg images/photo2.jpg images/photo3.jpg
touch scripts/backup.sh scripts/deploy.sh
touch temp/fichier1.tmp temp/fichier2.tmp
# 3. VΓ©rifiez la structure
ls -R
# 4. Copiez rapport.txt dans temp/
cp documents/rapport.txt temp/
# 5. DΓ©placez tous les .tmp vers documents/
mv temp/*.tmp documents/
# 6. Renommez backup.sh en sauvegarde.sh
mv scripts/backup.sh scripts/sauvegarde.sh
# 7. Supprimez le dossier temp (maintenant vide)
rmdir temp
# 8. VΓ©rifiez le rΓ©sultat final
ls -R
Verificationβ
Your final structure should be:
exercices_linux/
βββ documents/
β βββ fichier1.tmp
β βββ fichier2.tmp
β βββ notes.txt
β βββ rapport.txt
βββ images/
β βββ photo1.jpg
β βββ photo2.jpg
β βββ photo3.jpg
βββ scripts/
βββ deploy.sh
βββ sauvegarde.sh
π Back to table of contentsβ
4 - Mini-project: Organize a directory treeβ
Contextβ
You are a system administrator and must organize the files of a web project.
Goalβ
Create a complete project structure and document it.
Instructionsβ
# CrΓ©ez le projet
cd ~
mkdir -p projet_web/{src,public,config,logs,backup}
# CrΓ©ez les sous-dossiers
mkdir -p projet_web/src/{css,js,images}
mkdir -p projet_web/public/assets
mkdir -p projet_web/config/{dev,prod}
# CrΓ©ez des fichiers
touch projet_web/src/css/style.css
touch projet_web/src/js/app.js
touch projet_web/public/index.html
touch projet_web/config/dev/settings.json
touch projet_web/config/prod/settings.json
touch projet_web/logs/.gitkeep
touch projet_web/README.md
# Ajoutez du contenu au README
cat > projet_web/README.md << EOF
# Projet Web
## Structure
- src/ : Code source
- public/ : Fichiers publics
- config/ : Configuration
- logs/ : Fichiers de log
- backup/ : Sauvegardes
## Auteur
Votre nom
## Date
$(date +%Y-%m-%d)
EOF
Verificationβ
# Affichez l'arborescence
ls -R projet_web/
# Ou avec tree (si installΓ©)
tree projet_web/
# Affichez le README
cat projet_web/README.md
Expected structureβ
projet_web/
βββ README.md
βββ backup/
βββ config/
β βββ dev/
β β βββ settings.json
β βββ prod/
β βββ settings.json
βββ logs/
β βββ .gitkeep
βββ public/
β βββ assets/
β βββ index.html
βββ src/
βββ css/
β βββ style.css
βββ images/
βββ js/
βββ app.js
Bonusβ
# 1. Comptez le nombre de fichiers
find projet_web -type f | wc -l
# 2. Comptez le nombre de dossiers
find projet_web -type d | wc -l
# 3. Trouvez tous les fichiers .json
find projet_web -name "*.json"
# 4. CrΓ©ez une archive du projet
tar -czvf projet_web_backup.tar.gz projet_web/
π Back to table of contentsβ
5 - Next stepsβ
Congratulations!β
You have completed the Linux 1 - Fundamentals and First Steps course!
What you have learnedβ
Skills acquiredβ
| Skill | Mastery |
|---|---|
| Navigate the file system | β |
| Manage files and folders | β |
| View and search in files | β |
| Use nano and the basics of vim | β |
| Find help | β |
Next step: Linux 2β
In the Linux 2 - Basic Administration course, you will learn:
- User and group management
- Permissions and access rights
- Package management
- Processes and services
- Environment variables
- Redirections and pipes
Tips for making progressβ
- Practice daily: Use the terminal rather than the graphical interface
- Create a lab: Install VMs to experiment
- Read the man pages: Get into the habit of consulting
man - Make mistakes: You learn by breaking things (in a VM!)
- Automate: As soon as you repeat a task, script it
Recommended resourcesβ
| Type | Resource |
|---|---|
| Practice | Linux Journey |
| Reference | Arch Wiki |
| Exercises | OverTheWire Bandit |
| Book | "The Linux Command Line" (free online) |
Command summaryβ
| Command | Usage |
|---|---|
pwd | Display the current directory |
ls | List the contents |
cd | Change directory |
touch | Create an empty file |
mkdir | Create a directory |
cp | Copy |
mv | Move / Rename |
rm | Delete |
cat | Display the content |
less | View with pagination |
head | Beginning of a file |
tail | End of a file |
grep | Search for text |
man | Documentation |