Something broke: “command not found”, and the fan won’t stop
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
lsis a program file. The shell finds it by searching the folders listed in PATH, separated by colons.echo $PATHshows them; the usual ones are/usr/local/bin:/usr/bin:/bin(and thesbinversions). - 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 ~/.bashrcruns it again in this terminal, to test it. killasks politely. A program that ignores it can be stopped withkill -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.
Your task
Make ls and the other commands work again, in this terminal and in new ones, and stop the process that is using the CPU.
- Commands work again in this terminal (not done yet)
- New terminals will work too (not done yet)
- The CPU hog is stopped (not done yet)
The checklist ticks itself off as you work in the terminal: any way that gets the result counts.
Hints come one at a time, then one way to do it. Try each before the next.
What this lesson uses, in one place.
PATH- The folders the shell searches for programs, separated by colons
export- Set an environment variable More on export
source- Run a file’s commands in the current shell
kill -9- End it now More on kill
Every everyday command on one page: the Linux commands cheat sheet.