How Do You Save a Linux Machine where You Overwrote the PATH Variables Such That No Command Will Work?

Problem scenario
The server seems to be in a hopeless condition. You want to recover the server, but no commands in Linux are working. You get "command not found" with simple commands such as ls. You cannot use sudo, cat, rm, or reboot. What should you do?

Solution
Use absolute paths. For example, use this command:

/bin/sudo reboot

If there is a new file that is causing the problem, you can use /bin/vi to modify the file or /bin/rm to delete it.

Leave a comment

Your email address will not be published. Required fields are marked *