Linux / Unix: disown Command Examples

disown command

I am a new Linux and Unix shell user. How do I Remove or delete jobs from current bash / ksh or POSIX based shell?

Job control is nothing but the ability to stop/suspend the execution of processes (command) and continue/resume their execution as per your requirements. This is done using your operating system and shell such as bash/ksh or POSIX shell.[donotprint]

disown command details
DescriptionRemove jobs from
current shell
Root privilegesNo
Est. reading time5m
Table of contents
[/donotprint]You need to use bg command to restart a stopped background process. The fg command moves a background job in the current shell environment into the foreground. To delete/remove jobs or to tell the shell not to send a HUP signal use disown command. This command is part of bash or ksh93 shell.


Remove jobs from the table of active job.


The basic syntax is as follows:

disown jobID


disown jobID1 jobID2 ... jobIDN


disown [options] jobID1 jobID2 ... jobIDN

A note about BASH and KSH93 disown command
=> The disown command on ksh shell causes the shell not to send a HUP signal to each given job, or all active jobs if job is omitted, when a login shell terminates.
=>The disown command on bash shell can either remove jobs or causes the shell not to send a HUP signal to each given job or all jobs.
=> All examples, on this page are executed on bash shell either on OS X Unix or Ubuntu Linux.

disown command examples

Before you start using fg command, you need to start couple of jobs on your system for demonstration purpose. Type the following commands to start jobs:

xeyes &
gnome-calculator &
gedit &

Finally, run ping command in foreground:


To suspend ping command job hit the Ctrl-Z key sequence. Use the jobs -l command to list current jobs including a jobID:
$ jobs -l
Sample outputs:

[1]-  4581 Running                 xeyes &
[2]+  4584 Running                 ping &


  • [1] – jobID for process number (PID) 4581 for command ‘xeyes’
  • [2] – jobID for process number (PID) 4584 for command ‘ping’

Without any options, each jobID is removed from the table of active jobs i.e. the bash shell uses its notion of the current job which is displayed by + symbol in jobs -l command:
$ disown
Sample outputs:

Fig. 01: disown command in action

Fig. 01: disown command in action

How do I remove all jobs?

Pass the -a option to disown command, type:
$ disown -a
## You should not see any jobs running on screen ##
$ jobs -l

How do I remove only running jobs?

Pass the -r option to disown command, type:
$ disown -r
$ jobs -l

How do I keep running job after I exit from a shell prompt in background?

The SIGHUP (Hangup) signal is used by your system on controlling terminal or death of controlling process. You can use SIGHUP to reload configuration files and open/close log files too. In other words if you logout from your terminal all running jobs will be terminated. To avoid this you can pass the -h option to disown command. This option mark each jobID so that SIGHUP is not sent to the job if the shell receives a SIGHUP. The syntax is:
$ disown -h jobID
$ disown -h %2

Job IDs begin with the % character; %n identifies job n, while %% identifies the current job. In this following example, update the Debian or Ubuntu Linux based server using apt-get command in background:

## Step 1: update system ##
apt-get upgrade &> /root/system.update.log &
## Step 2: Mark apt-get so that SIGHUP is not sent when you exit and go for tea ##
disown -h 
## Step 3: exit from root shell ##

Please note that you can also use nohup command to set the signal SIGHUP to be ignored for any command on Linux or Unix for same purpose.

disown command options

From the bash(1) command man page:

Option Description
-a Delete all jobs if jobID is not supplied.
-h Mark each jobID so that SIGHUP is not sent to the job if the shell receives a SIGHUP.
-r Delete only running jobs.

Related media

This tutorial is also available in a quick video format:

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • Ryan McCain May 28, 2014 @ 23:52

    This is great stuff. I never knew about disown -h

  • Marc Apr 17, 2015 @ 15:58

    This tutorial would have been infinitely more useful if it actually specified what jobId is and/or how to get it, and gave an example. It doesn’t so unfortunately this tutorial is useless to me.

    • henryford May 20, 2015 @ 13:06

      You know, you could have just read the post carefully – because it explitically mentions how to get the jobID:

      Use the jobs -l command to list current jobs including a jobID:
      $ jobs -l

  • Matthew Passell May 5, 2015 @ 15:23

    Very useful post. After running “disown -h” on a given job, is there any way to see that it has taken effect? Maybe something in ps? It doesn’t look like there’s any difference in the output of “jobs” or “jobs -l” after running the command.

  • Thomas Mayer Jul 9, 2015 @ 9:01

    Very useful information, but I have a question. Is there any command that allows you to ‘own’ a proccess? For example, for a disowned a job, something that allows you to get back the control of the proccess given by its PID. Thanks in advance.

  • Tom Feb 25, 2016 @ 20:22

    Is there any way to reown the job after doing disown?

  • Tristan Mar 20, 2017 @ 16:04

    It looks like on Ubuntu (server or desktop), whithout using “disown”, when I exit a terminal after launching jobs in background, the jobs are not terminated, they take a parent process as their parent.

    Is it only happening on Ubuntu ? Or is this the new standard behaviour ?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum