Insufficient memory to execute commands

If you have played with Linux computers for a while, it is possible that in some ocassions one of them run out of memory for some reason. In this situation it is impossible to run simple commands such as ls. Recently I’ve read a little trick from Prentice Bisbal at Linux Journal that may help.

From Prentice…

About five years ago, a Linux system I was responsible for ran out of memory. Even simple commands, such as ls, failed with an insufficient memory error. The obvious solution to this problem was simply to reboot. One of the other system administrators wanted to look at a file that may have held clues to the problem, but he couldn’t remember the exact name of the file. We could switch to different directories, because the cd command is part of bash, but we couldn’t get a list of the files, because even ls would fail. To get around this problem, the other system administrator created a simple loop to show us the files in the directory:

$ for file in *; do echo $file; done

This worked when ls wouldn’t, because echo is a part of the bash shell, so it already
is loaded into memory. It’s an interesting solution to an unusual problem.

Cool! Isn’t it? Thanks to Prentice Bisbal.

Leave a Reply

You must be logged in to post a comment.