After executing a command in the terminal, I sometimes can't execute another

Solution 1:

If what you're really trying to do is start a GUI program from the terminal, you may prefer something like

geany filename.php &

which will start it in the background, since it doesn't need the terminal for anything. This may also work for the node.js application, if it doesn't require the terminal for anything.

If they're still running when you close the terminal, it will complain. If you really want them to stick around after the terminal exits, use disown.

Solution 2:

After you start a process (job), you can still do other things. You might want to write these down as a cheat sheet.

  1. Ctrl+c Kill the running process (foreground job)
  2. Ctrl+z Pause running process (foreground job) and return to the prompt
  3. Type jobs Shows you all background jobs on the terminal
  4. Type bg Makes the last paused job continue in the background
  5. Type fg Returns the last pause job to the foreground

You can also type bg or fg with a number after, like fg 3. This will bring job #3 to the foreground.

If you are going to background a process, and you don't want it outputting a bunch of text, just put > filename.txt after it, like this process > out.txt. This will make it send all standard output to the file out.txt (and not clutter your terminal).

If you use terminals often (like me :) then you definitely want to install and become familiar with the terminal program called screen. It allows you to have multiple virtual terminals in 1 window, and if you close the terminal window (on accident?), you can reopen it exactly where you left off from before.

Solution 3:

Ah, you're hitting the wrong key. It's Control + C. This is the command to force the current running application in the terminal to end. If you end the command it will also end the corresponding open application. So if you want to execute more commands in the same terminal, you have to press Control + C to exit the program, which will also exit geany. So it's best to simply run programs through the GUI, therefore saving you a lot of terminal windows. Or you can also use Ubuntu's run command function by pressing Alt + F2 and typing the command you want to run, no terminal required.