Live data from Hacker News

Awesome but commonly unknown Linux Commands

anchor.com.au

81–88 of 88 posts

Re: Awesome but commonly unknown Linux Commands

#81
post #53

Earlier quoted context omitted.

Similar experience here, except that I've solved similar issues (and far more complicated issues) with DTrace instead of strace. The range of information that DTrace can retrieve about a running application surpasses anything that strace can retrieve. DTrace can retrieve information on a systemic scale, whereas each strace instance operates on a single process. And the overhead is significantly lower with DTrace. For…

systemtap is another utility in this vein that's worth checking out http://sourceware.org/systemtap/

I already checked it out and the timer probes don't work at all.

On one system, I couldn't even invoke kernel functions.

On another system, the kernel panicked as soon as I executed `stap -e ...`.

Basically unusable, at this point.

I hope it improves because developers on linux could really benefit from dynamic tracing.

Re: Awesome but commonly unknown Linux Commands

#82

Meh, I was hoping for at least semi obscure things like the 'moreutils' utils. Speaking of which, many people don't know about the 'moreutils' utils. Check them out ;)

I see sponge is somehow useless, how is `| sponge /etc/passwd` different from `> /etc/passwd`.

He explained it on the site - if you are trying to use grep to trim contents from a file and output them to the same file, you will end up with an empty file.

Seriously though - everyone knows this. Just use a temp file.

He says sponge "keeps the results in memory" - that's a problem if the file is huge.

Plus there are other tools to do in-place replacement.

Re: Awesome but commonly unknown Linux Commands

#83
post #6
post #5

Earlier quoted context omitted.

You can also use `cd -` to return to the previous directory.

git "borrowed" this idea too. You can use `git checkout -` to checkout the last thing you checked out; very handy when merging.

in bash you can use $_ to access the last argument of the previous command. It lets you do things like this:

    $ pwd
    /home/foo
    $ mkdir -p bar/baz/qux && cd $_
    $ pwd
    /home/foo/bar/baz/qux

Re: Awesome but commonly unknown Linux Commands

#85
post #59

If you're running a modern Linux desktop, you should have a "notify-send" command which will cause a message to be displayed by your desktop-environment's pop-up notification system (on Ubuntu, this command is in the libnotify-bin package). I have two scripts I keep around which I call "notify-success" and "notify-failure": notify-success: notify-send --icon=gtk-dialog-info Success! "$*" notify-failure: notify-send -…

On a mac, you could also use growlnotify. growlnotify -m "Hey I am done!" -t "Done!"

Also useful is the `-s` option to make the notification sticky

    growlnotify -s -t 'Done!' -m 'And I'm not going away until you click me'

Re: Awesome but commonly unknown Linux Commands

#86

Earlier quoted context omitted.

To be fair, that's not even a command; that's a shell expansion that automatically substitutes your previous command in place of the !! before executing it.

Thank you for another '...and this is why I love HN' moment.

Just be aware it may not execute the command you think. man bash for HISTIGNORE. Personally I never use it with sudo; it's too dangerous.

Re: Awesome but commonly unknown Linux Commands

#87

Earlier quoted context omitted.

find -exec is almost always faster and more secure than xargs.

Does find have an equivalent for xargs "-P max" flag?

You can emulate it with sem:

    find . -exec sem --id my_find -j3 sleep 4\; echo {} \;
See more about sem: http://www.gnu.org/software/parallel/sem.html

Re: Awesome but commonly unknown Linux Commands

#88
post #86

Earlier quoted context omitted.

Thank you for another '...and this is why I love HN' moment.

Just be aware it may not execute the command you think. man bash for HISTIGNORE. Personally I never use it with sudo; it's too dangerous.

This is also why I disabled HISTIGNORE in both bash and zshell. zshell also allows me to press TAB to expand the command in-place before I press enter, so I can still use the shortcut without the danger.
Post reply on HN