Skip to content

Something broke: “command not found”, and the fan won’t stop

NinjaLesson 65 of 6612 min

A troubleshooting challenge: an installer broke your PATH and left a process that ignores kill. Get your commands back for good, and stop it.

You installed a file-sync tool. Now every new terminal says ls: command not found, and the laptop's fan hasn't stopped since. Get your commands back, in this terminal and in every new one, and stop whatever is eating the CPU.

Some things to keep in mind:

  • A command like ls is a program file. The shell finds it by searching the folders listed in PATH, separated by colons. echo $PATH shows them; the usual ones are /usr/local/bin:/usr/bin:/bin (and the sbin versions).
  • Commands built into the shell (echo, cd, export, kill) work without PATH. Any program works by its full path, such as /usr/bin/ps.
  • A new terminal reads ~/.bashrc, so a mistake there comes back every time until you fix the file. source ~/.bashrc runs it again in this terminal, to test it.
  • kill asks politely. A program that ignores it can be stopped with kill -9, which can't be ignored, and also gives it no chance to clean up. Use it only when the polite way fails.

The laptop is a pretend one inside this page. Reset puts it back as it was.

Your turn

Make ls and the other commands work again, in this terminal and in new ones, and stop the process that is using the CPU.

Next