How to use nohup command in Linux?

When you execute a command in a Linux system it starts a process and when you exit from the terminal it gets automatically terminated. In some situations, you may want to keep running a process even after exiting from the terminal. So how will you do that?

Well, we can use nohup (No Hang Up) command which keeps processes running even after you close your terminal. It prevents the processes from receiving the SIGHUP signal which is the signal sent to a process when its controlling terminal is closed.

In this article, I will discuss the usage of nohup command along with some examples.

Syntax of nohup command in Linux

The syntax of how to use nohup command in Linux is given below.

nohup command [ argument.. ]

Now let’s see some usage of this command.

Usage of nohup command in Linux

The following examples show the usage of nohup command in Linux.

Check the version of nohup command

Use the given command to see the version of nohup installed in your system.

nohup --version

This will display the output as given in the image below.

nohup version

Starting a process using nohup command

When you run a command using nohup command this will start a process that will run even after you exit from the terminal.

For example –

Let’s say we have a sample file called to execute this use –

nohup bash

This will execute the given file and append the output to nohup.out

use nohup command

Now you can see the output which is saved in nohup.out file by using the given command –


testfile output

If you want to redirect the output to a specific file then use –

nohup bash > output.txt

Start a process in the background

You can run a command in the background by appending the & symbol at the end of the command.

For example –

nohup bash &

If you want to bring the process to the foreground then use fg command.

nohup background

You can see help on nohup command by using –

nohup --help


I hope now you understand the usage of nohup command in Linux. Now if you have a query then write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version