What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Job Control

Terminal - Job Control
^Z $bg $disown
2009-03-17 21:52:52
User: fall0ut
Job Control

You're running a script, command, whatever.. You don't expect it to take long, now 5pm has rolled around and you're ready to go home... Wait, it's still running... You forgot to nohup it before running it... Suspend it, send it to the background, then disown it... The ouput wont go anywhere, but at least the command will still run...


There is 1 alternative - vote for the best!

Terminal - Alternatives
disown -a && exit
^z; bg; disown
2011-12-06 20:48:01
User: anarcat

background and disown, but with a proper one-line syntax

Know a better way?

If you can do better, submit your command here.

What others think

and the values for "$bg" and "$disown" would be?

Comment by linuxrawkstar 375 weeks and 4 days ago

Thank you very much for the pointer to 'disown'. Now I can get rid of the '[1]+ Done' messages I receive from background tasks in my local.start script.

Comment by Alanceil 375 weeks and 4 days ago



bg and disown without values will affect your last job, for options see the bash man page:

disown [-ar] [-h] [jobspec ...]

Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP

is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.

Comment by Alanceil 375 weeks and 4 days ago

the $ signs in front of the bg and disown commandos are just wrong.

Comment by cran 375 weeks and 4 days ago

@cran - I figured as much. Misleading and detrimental.

Comment by linuxrawkstar 375 weeks and 4 days ago

ok for this to work:

1) start long running process

2) hit CTRL+Z

3) type bg

4) type disown -h

5) close terminal


test it by reopening terminal and grepping for the process in the process table (ps -afx)

Comment by linuxrawkstar 375 weeks and 4 days ago

Ok, disown was unknown to me. thanks!

Comment by unixmonkey2431 375 weeks and 3 days ago

Looking up the manpage for bash, disown is mentioned, to my surprise. Reminds me what my unix sensei taught me: never forget to try the manpages.

After some googling, the best way to do this in one swoop is to use the 'nohup' command, which is a program (part of GNU coreutils), and is not built-in to bash:

nohup command &

That will have the effect of disown-ing the process, avoiding it dying when the launching shell dies and backgrounding it at the same time.

Comment by bwoodacre 375 weeks and 3 days ago

How can I get the process to be 'own'ed by another shell ?

Comment by naseer 375 weeks ago

@naseer: That's impossible without running the process in something like GNU Screen ahead of time. However, it is possible in BSD to do

sudo watch -W <tty path>

and "reattach" to another tty. A program called "ttysnoop" should allow similar behavior, but I'm not very familiar with it. In the end, it's impossible to "re-own" a regular job after it's been disowned.

Comment by woxidu 374 weeks and 2 days ago

Just to clarify for linux users: BSD's "watch" is completely different from Linux's "watch"

Comment by woxidu 374 weeks and 2 days ago

What about correcting the command so that it actually works? The version of linuxrawkstar worked.

Comment by Svish 374 weeks and 1 day ago

In this case the command isn't a one-liner, it's a several-liner. What is our procedure for handling something like this?

Still a good thing to know, though.

Comment by nitehawk 370 weeks and 5 days ago

Your point of view

You must be signed in to comment.