Final challenge: fact-check the AI
You asked a chatbot how to set up a small Python project that will talk to a local AI model. It answered instantly and confidently. It's also wrong in five places, and one of them could wipe your home folder. Set the project up correctly on this server.
Sure! Here's how to set up your helper project on Linux:
- Make the folder and give it full permissions so the script can run:
mkdir ~/helper && chmod 777 ~/helper - Install the library:
sudo pip install ollama - Save your code as
~/helper/ask.py(starting withimport ollama), make it runnable and start it withpython ask.py. - For a nice view of your project, install tree:
sudo apt install tree - If anything goes wrong, clean up and start over with:
rm -rf ~/ helper
Hope this helps! 😊
The objectives say what a correct setup looks like. Check each suggestion before you run it: explain, man and the lessons are your fact-checkers. The practice server can't run Python programs, but it can check that everything is set up the way a real one would need.
The brief
- A runnable script, safely.
~/helper/ask.pyexists, starts with a line that says which program runs it (Python 3), and you can execute it. Nothing in~/helperis writable by everybody. - The library in the right place. A virtual environment inside
~/helperhas theollamalibrary installed. - The right tool.
treeis installed, with the package manager this server actually uses. - Home folder survives. You checked the clean-up command with
explainormanbefore doing anything with it, and you never ran it.
Stuck? Hints
Open only as many as you need.
1. A runnable script
777 means anyone on the machine may change your script. Only the owner needs to run it: chmod u+x (or chmod 755). Without a first line like #!/usr/bin/env python3, Linux runs the file with bash, and you'll see import: command not found.
Still stuck: Linux Basics, lesson 10 and Linux Sysadmin, lesson 13.
2. The library
sudo pip installs into the system's own Python, which the package manager looks after. Make a venv (python3 -m venv ~/helper/venv), activate it, then pip install. On Ubuntu, the venv module is a separate package.
Still stuck: lesson 2.
3. The right tool
cat /etc/os-release tells you which family you're on. apt is the Debian family's; the RHEL family uses dnf.
Still stuck: Linux Basics, lesson 11.
4. Home folder survives
Look very closely at the space in rm -rf ~/ helper. Ask explain rm -rf ~/ helper what it would do. The safe version has no space, and you only need it if you really want to start over.
Still stuck: lesson 1.