Using AI to write Linux commands without breaking your server

AI writes Linux commands fast and almost always well, but “almost always” is not much when the command deletes files. The rule is simple: ask for an explanation of each part, try it somewhere that is not the server that matters, start with commands that only read, and have a backup ready before anything that changes things. On an unmanaged VPS there is nobody to undo a mistake for you.

The method, step by step

1 Tell it what you have. The system version (cat /etc/os-release), what you want to do and what you have tried. Commands from one distribution may not exist on another.
2 Ask for the explanation, part by part. “Explain each option in this command and tell me what happens if I get it wrong.” If you do not understand a part, do not run it.
3 Check the manual. See the options with man command or command --help. The AI makes up options that do not exist.
4 Start by only reading. Commands such as ls, cat, df -h and free -h change nothing. See the state before you change it.
5 Back up before changing. A VPS snapshot, or a copy of the file you are about to edit. See backing up a VPS.
6 Try it on a test server when you can, and run one command at a time, looking at each result.

The patterns that do damage

Pattern Why it is dangerous What to do
rm -rf with a path or variable If the path comes out empty or wrong, it deletes what it should not List what it will delete with ls first
chmod -R 777 Gives everybody full permission and opens the door to attacks Ask for the right permission and explain the case
curl ... | bash Runs a script from the internet without you reading it Download it, read it and only then run it
Firewall rules copied blindly Can lock you out of your own server Try with a spare SSH session open. See losing SSH access.
Editing the SSH configuration One mistake cuts your access Keep a session open while you test the new one
Commands with sudo by habit Gives the mistake the power of root Use the normal user whenever you can
Do not paste passwords, keys or configuration files holding secrets into the chat with the AI. Remove them from the text before pasting. See keeping keys safe.

A prompt that works well:

I have a VPS running [system and version]. I want to [goal].
Give me the commands one at a time and explain every option.
Say what each command changes and how to undo it.
Start with the ones that only read. Warn me about anything irreversible.

If the AI gives you a long, complicated command, ask for a simpler version or one in steps. A command you cannot explain to someone else is a command you should not run.

Locked out of the server after a command? Open a ticket and tell us what you ran.

Open a support ticket

SEE ALSO

Keeping your VPS or dedicated server secure: the six that matter

I have lost SSH access to my server: the four usual causes

AI hallucinations: how to check an answer before you use it

First steps with your VPS

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from 5.940,00 Kz/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?