Saturday, June 23, 2012

The Power of Ctrl-Z

When working in the Linux shell I have often erroneously hit the ctrl-z "panic" button in a feeble attempt to undo a mistake I've made.  However, this habit comes from years of using GUI applications and in Linux takes on an entirely different meaning.  Instead of happily seeing my mistake fixed, I usually end up back at the prompt with some text as follows:
[1]+ Stopped                 vi back-end/upload.php
Most times I would utter a curse under my breath, and reopen whatever application I was working in (often VIM).
Today, I learned that in pressing Ctrl-Z, I have backgrounded the application I was using.  This would be equivalent dropping back to the desktop in the GUI world.  Essentially, the prompt is your desktop, after pressing Ctrl-Z you are sent back to the prompt and you are given the job number of the application you were working in (the number inside the square brackets).  To reopen an application, you call the foregrounding program, fg, with the job number as a parameter.  This site is where I learned this info.

Super useful!

No comments: