Dec 22, 2025
Aris S.
6min Read
The no hang up or nohup command allows processes in your Linux system to keep running even after the terminal closes. This is essential for system administrators, as it helps prevent long-running tasks like builds or monitoring from being interrupted.
Using the nohup command is straightforward: simply enter it in your system’s terminal, followed by the process you want to run continuously. Beyond basic usage, you can use it to run tasks in the background and redirect output to a specific file.
In this article, we’ll cover usage of the nohup command in more detail, as well as its real-world applications.
Linux sends the hang-up signal (SIGHUP) to terminate all processes in the shell when you close the terminal. This can also happen in a remote system due to connectivity issues.
To restart the processes, you must manually reenter the Linux commands or scripts. This can be tedious and time-consuming if there are many long-running tasks.
The nohup command blocks the processes from receiving the SIGHUP signal, keeping them running even after terminal exit.
The nohup command is helpful for maintaining continuous tasks. Here are some examples of popular use cases for system administrators and developers:
The nohup command syntax is structured as follows:
nohup command [options]
Here’s the breakdown of the syntax:
The nohup command options are as follows:
You can run the following command to check the nohup version:
nohup --version

Here are several nohup command examples in a real-world scenario. To follow along, open your system’s terminal or the browser terminal if you use a Linux virtual private server (VPS) from Hostinger.

To run a process indefinitely, use the basic nohup command syntax as follows:
nohup process
For example, enter the following to run a simple Bash shell script that prints a Hello world! message:
nohup ./script.sh
After running nohup, you can see the process’s output from the nohup.out file. Check its content using the following cat command:
cat nohup.out

To save the output of processes run using nohup to another file, use the redirection operator (>) like so:
nohup ./script.sh > file.txt
Check the saved output by printing the file’s content using the cat command:
cat file.txt

Note that the above redirection operator will overwrite the file with the new output. If you want to append the existing content, use the following operator:
nohup ./script.sh >> file.txt
In some cases, nohup doesn’t automatically redirect errors, meaning you must do it manually. For example, the following will log the process’s output and errors to file.txt:
nohup ./script.sh > file.txt 2>&1
Here’s the breakdown of the command:
In the Bash shell, the command can also look like the following:
nohup ./script.sh &> file.txt
If you want to append errors, simply use the >> redirection instead of > like so:
nohup ./script.sh >> file.txt 2>&1
You can also save the nohup process’s output and errors in separate files like so:
nohup ./script.sh > output.txt > errors.txt
Note that there’s no space between the redirection operator and stdout or stderr.
By default, the nohup command will run a process in the main terminal shell. This means that you must terminate it to run other utilities, which can be problematic if you have multiple tasks.
As a workaround, nohup provides the & option to let you run the process in the background. This enables you to use the main shell for other tasks even when the process is running. Here’s how the command looks:
nohup process &
When running nohup in the background, your terminal will give an output similar to this:
[1] 1234

The [1] placeholder represents the background process’s order in the current terminal shell. For example, [1] means the first, [2] is the second, and so on.
Meanwhile, 1234 is the job’s process ID (PID). This information is essential for identifying and stopping the process, which we’ll explain later.
To check running processes started using nohup, use the ps command followed by their PID. Here’s the command:
ps -p PID
The process is running if the terminal outputs the executed command or script name.

If you forget the PID, use pgrep to check a nohup process’s status using its command or script name, like so:
pgrep -a process-name
For example, enter the following if you want to check if the sleep command is running:
pgrep -a sleep
If you forget both the PID and process name, use the lsof command to check jobs that use the nohup output file:
lsof | grep nohup.out

Your terminal will list commands and scripts run using nohup, along with their PID. Remember to replace nohup.out if you redirected the output to another file.
To stop a nohup process that is running in the main shell, hit the Ctrl + C shortcut on your keyboard to send the SIGTERM signal – a graceful termination method that allows the task to finish first before stopping.
If you run a nohup task in the background, the only way to stop it is to use the kill command, which lets you kill a process in Linux using its PID. The syntax is as follows:
kill PID
For example, here’s a command to terminate a process with a PID of 1234:
kill 1234
By default, the kill command will send the SIGTERM signal, which may not be enough to stop an unresponsive process. In this case, use the SIGKILL signal to forcefully terminate the task.
To pass the SIGKILL termination signal using the kill command, add the -9 option:
kill -9 PID
Note that you can’t bring nohup processes from the background to the foreground or the main shell. This is because nohup isn’t interactive and doesn’t register your tasks as jobs, which are manageable using the fg or bg command.
If you wish to interact with background processes, run them using alternative tools that we’ll explain in the next section.
In addition to nohup, Linux has other tools that let you run commands in the background. Here are some popular options.
GNU Screen
The GNU Screen is a terminal multiplexer that enables you to create virtual shell sessions that remain active in the background.
Since Screen is interactive, it’s an excellent alternative to nohup if you wish to manage and switch between processes easily.
tmux
Terminal multiplexer (tmux) is a more modern and user-friendly Screen alternative. This tool has features like better window splitting and an intuitive user interface, which makes it easier to use than Screen.
However, tmux’s deeper functionality also makes it more challenging to learn than Screen.
systemd-run
The systemd-run command runs processes as a service, which is more reliable because your tasks have better isolation, dependency handling, and failover mechanisms.
However, systemd-run is only available in systemd-based operating systems. It’s also more complicated to set up than nohup since you must configure the process as a service.
Docker
Docker is a containerization tool for running processes in dedicated environments, with their own resource constraints and software setup. Since tasks can run independently from others, it provides a high level of isolation and reliability.
Docker is excessive for simple tasks that you usually run with nohup because it can be challenging to set up and manage. It’s ideal for complex processes, like setting up a consistent deployment pipeline.
The nohup command is a handy tool for keeping simple processes running in the background. It is especially useful when working with a remote server where a connection issue may end the terminal session.
Note that nohup is most suitable for simple, one-off processes. For more complex tasks, consider an alternative tool with interactive functionality like Screen.
Once you’ve grasped the purpose of the nohup command, try it on your system’s terminal or in Hostinger’s VPS browser terminal. Hostinger’s VPS hosting also gives you the option to ask Kodee, an AI assistant, for help if you need it.