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.

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





Maintained by Jon H.

Site originally by David Winterbottom (user root).

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

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 are 3 alternatives - 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 413 weeks and 5 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 413 weeks and 5 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 413 weeks and 5 days ago

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

Comment by cran 413 weeks and 5 days ago

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

Comment by linuxrawkstar 413 weeks and 5 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 413 weeks and 4 days ago

Ok, disown was unknown to me. thanks!

Comment by unixmonkey2431 413 weeks and 4 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 413 weeks and 3 days ago

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

Comment by naseer 413 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 412 weeks and 2 days ago

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

Comment by woxidu 412 weeks and 2 days ago

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

Comment by Svish 412 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 408 weeks and 5 days ago

Your point of view

You must be signed in to comment.