System and processes

The nohup command

Runs a command so it keeps working even if you close the terminal. Output is saved to nohup.out.

Syntax

nohup COMANDO [&]

Most useful options

&It is almost always used with & to leave it in the background

Copy-ready examples

$ nohup sleep 30 &Launch it and let it survive closing
$ nohup ping -c 100 google.com > ping.txt &Save the output to a file

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • Without & the command stays tied to the terminal: if you close it, it goes.
  • If you do not redirect the output, it ends up in nohup.out in the current directory.

Related commands

FAQ

Does it stay alive if I close the session?

Yes: that is exactly its purpose, to survive closing the terminal.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course