Hide

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.
Hide

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:

Hide

News

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!
Hide

Top Tags

Hide

Functions

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

Runs a command without hangups.

Terminal - Runs a command without hangups.
nohup <command> &
2009-02-19 14:45:04
User: gnawa
Functions: nohup
6
Runs a command without hangups.

puts command in background and sends its output to nohup.out file

it will not die if you log out fromyour shell session ;-)

Alternatives

There are 8 alternatives - vote for the best!

Terminal - Alternatives
screen -d -m command &
2010-06-22 18:24:22
Functions: command screen
5

The improvement is that you can re-attach to the screen at a later point.

Know a better way?

If you can do better, submit your command here.

What others think

i don't want my commands to die, but PLEASE let nohup die. stop using it and welcome to the 1980s and job control. fricking nohup.out files all over the damn place. jesus.

Comment by wwest4 392 weeks and 2 days ago

so show we how to do the same only with your "job control"

thank you.

Comment by gnawa 392 weeks and 2 days ago

Job control is still handy, and necessary, in the shell. Signal handling is really essential for network programming, and this is essentially what you're doing when you detach processes from each other. You're controlling the flow of signals through your processes.

exec accomplishes the same thing, without the output file. nohup.out files can get big, and this is one reason not to use it.

It detaches the process from the terminal, so when the terminal receives a SIGHUP or SIGKILL, it is not passed through to the child processes.

Also see & for background processes, and "jobs" to see what you've placed in the background. Signal handling rocks.

Comment by gloriajw 392 weeks and 2 days ago

nice explanation gloriajw, thank you :D

Comment by gnawa 392 weeks and 2 days ago

modern shells either 1) do not pass sighup/sigkill to backgrounded child procs, or 2) provide a builtin to disown child procs. nohup is 99% obsolete.

Comment by wwest4 392 weeks and 2 days ago

better use screen for this: http://www.gnu.org/software/screen/screen.html

Comment by dizzgo 392 weeks and 2 days ago

This isn't true in Debian, unfortunately. Sigkill is passed through from bash to child processes. I just taught these young guys I work with about exec, and they thanked me greatly, because they could not figure out what was going on.

Comment by gloriajw 392 weeks and 2 days ago

dizzgo, I came here to say the same thing. Why use hup when screen is everything -- and more?

Comment by ozymandias 392 weeks and 2 days ago

What about doing it this way?

(somecommand > /dev/null 2>&1 &)

Enclosing your command disowns the process from your terminal (similar to nohup'ing). The '> /dev/null 2>&1 &' redirects standard out and standard error to /dev/null and the & runs the whole thing in the background.

Is use this all the time at work to kick off commands that I know are going to take a few hours to run, but I don't care about the output. I run the command, logout and go home.

Is there a better way to do it?

Comment by hkyeakley 392 weeks and 2 days ago

gloriajw: in bash the builtin is 'disown' i think, though on most of the boxes i use these days, it's unnecessary. exec is nice. I dig the parenthetical enclosure method... didn't know that orphaned the enclosed command.

Comment by wwest4 392 weeks and 2 days ago

Your point of view

You must be signed in to comment.