AI as your Linux sidekick
AI chatbots like Claude, ChatGPT and Gemini are amazing Linux tutors. They're patient, awake at 2am, and happy to explain an error ten different ways. But they can also be confidently wrong, and on Linux a wrong command can do real damage. Here's how to get the good without the bad.
You will learn
- How to write a question that gets a useful, correct answer
- What you must never paste into an AI chat
- How to spot risky or wrong AI answers before you run them
What AI is great at
- Explaining a command you found online, piece by piece
- Translating error messages into plain English
- Translating between families: “How do I do this Ubuntu tutorial on Rocky?”
- Quizzing you: “Give me 5 practice questions about ls and cd”
Why AI gets Linux wrong
An AI has read millions of tutorials, and they don't agree with each other. Half were written for Ubuntu and half for Rocky, some for versions from ten years ago. If you don't say which Linux you're on, the AI has to guess. That's how people on Rocky end up being told to run apt. The AI also can't see your screen, so it only knows what you tell it.
Always tell the AI which distro and version you're on. Run this and paste the PRETTY_NAME line:
cat /etc/os-release
A question template that works
Copy this and fill in the blanks. The more exact you are, the better the answer:
I'm a beginner learning Linux.
System: Rocky Linux 9.6 (from cat /etc/os-release)
Goal: I want to install a web server and see my own page.
What I ran:
sudo apt install apache2
What happened (exact error, copied):
bash: apt: command not found
Please explain what went wrong in simple terms. Then give me the
commands for MY system one at a time, and explain what each part does.
Notice the last line. Asking the AI to explain each part turns it from a vending machine into a teacher, and it makes wrong answers easier to spot.
Never paste these
- Passwords, including the one for your school account and your sudo password
- Your SSH private key (
~/.ssh/id_ed25519, the file without.pub) - API keys and tokens: long random strings, often starting with things like
sk-orghp_ - Other people's personal info from log files (names, emails, IP addresses)
If a command's output has a secret in it, replace it with XXXX before pasting. Treat anything you paste into an online service as if it could become public.
Red flags 🚩: think before you run
Before you run any command from an AI (or a random website), check it against this list:
| If the answer contains… | Why it's risky | What to do instead |
|---|---|---|
rm -rf | Deletes everything under a path, forever, without asking. | Read the path twice. Run ls on it first to see what would be deleted. |
chmod 777 or chmod -R 777 | Lets everyone read, change and run the files. A huge security hole. | Ask: “What's the minimum permission I need, and why?” |
curl … | sh or | sudo bash | Downloads a script and runs it without anyone reading it. | Only from sites you trust. Download it first, read it, then run it. |
setenforce 0, “disable SELinux”, ufw disable | Makes the error go away by switching off security. | Ask how to allow exactly the one thing you need. |
apt on Rocky, or dnf on Ubuntu | Wrong family. The AI guessed your distro. | Tell it your distro (rule #1) and ask again. |
A flag you can't find in man | AIs sometimes make up options that sound right but don't exist. | Check man COMMAND or COMMAND --help. |
Spot the bad answer
Each of these is the kind of answer an AI might really give. What's wrong with it?
1. You're on Rocky Linux and ask how to install nginx. The AI says: sudo apt update && sudo apt install nginx
✓ The AI assumed Ubuntu. Always include your distro in the question.
2. You get “Permission denied” writing to /var/www/html. The AI says: sudo chmod -R 777 /var
✓ “It works” and “it's a good idea” are different things. Fix the smallest thing possible.
3. The AI says “to see hidden files, run ls --show-hidden.” You try it and get “unrecognized option.” What happened?
✓ That's called a hallucination. The man page is the source of truth.
4. You're SSH'd into an Ubuntu server and ask how to turn on the firewall. The AI says: sudo ufw enable. What's missing?
✓ You learned this in Linux Basics, lesson 14. That's a mistake you can now catch before the AI's advice bites you.
AI that runs commands for you
Some AI tools (called agents, like coding assistants in your terminal) can run commands on your computer by themselves. They can be really useful, and all the same rules apply. Read what they want to run before you approve it, keep them away from secrets, and try them on a practice machine first, never on a server other people depend on.
Try it: be the fact-checker
This practice terminal has a built-in helper called explain. It's not a real Linux command, just a tutor. Use it, and man, to check commands before running them.