What is Nohup and how do you use it?

What is Nohup and how do you use it?

Many commands are available on Linux systems. There are some that you will use several times a day and others that are generally reserved for particular use cases. nohup is one of those commands. You won’t be using it every day, but you’ll be thankful that it’s there when you need it. Here we show you what nohup is and how to use it.

What is Nohup?

nohup is the abbreviation for “No Hangups”. It is not a command that you run alone. nohup is an additional command that tells the Linux system not to stop a command once it has started. This means that it will continue to run until it is finished, even if the user who started it logs out. It serves a somewhat similar purpose to tmux or screen, allowing you to start a process without worrying about whether it will end if you log out or get logged out of your server. The syntax of nohup is simple and looks like this:

Note the “&” at the end of the command. This moves the command to the background, freeing up the terminal you are working in.

nohup works with pretty much any command you run in terminal. It can be run with custom scripts as well as standard system commands and command line utilities. You can use it to start a security audit script on a remote server and be able to log off and walk away, or you can just use it if you want to run updates in the background and not do them. stop for anything.


Because nohup can continue to run regardless of who started it, the command needs a place to display messages or errors. Since there is no terminal to associate with it, nohup save everything to an output file, nohup.out.

By default, this file is located in the directory where you issued the command. nohup.out is somewhat unique in that it contains both standard output and error output. nohup redirects both to the same file by default.

Nohup exit

You don’t necessarily need to use nohup.out, however – it’s just the default. You can specify custom output when you run nohup and place it in a custom location.

Custom output contains exactly the same data as the standard nohup.out file would be. This is fine for the security audit script I mentioned above. You can name it audit-script-output.txt in some sort of mounted remote folder and view the security position of that server from the comfort of your own laptop rather than looking through cat outings all day.

How is Nohup different from a demon?

At this point, you are probably wondering which sets nohup outside of a demonized process. After all, they both seem to serve the same purpose, but they really don’t.

The demons run continuously in the background. It’s best to reserve them for processes you never want to quit, like servers. They also require more work to program, so they’re not the best for simple, one-time scripts.

nohup is for single use only. Think of a script that will take a long time to run but will always end up eventually. There might be a long and complicated task that you do every now and then that takes hours. You don’t want to leave a terminal open or a user logged in, so you use nohup to make it work in the background and put all the output in the file of your choice, than the default nohup.out or your chosen location.

If you enjoyed this article on nohup, its benefits and uses, be sure to check out some of our other Linux content, like our explanation of file permissions or how to speed up a slow Linux machine.


Is this article useful?

John perkins
John perkins

John is a young technical professional with a passion for educating users on the best ways to use their technology. He holds technical certifications covering topics ranging from computer hardware and cybersecurity to Linux system administration.


More Similar Posts

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed