Live data from Hacker News

Awesome but commonly unknown Linux Commands

anchor.com.au

61–70 of 88 posts

Re: Awesome but commonly unknown Linux Commands

#61
post #24

All these article links should just end up here: http://www.commandlinefu.com/commands/browse you can sort by date, #(votes) and also search The top all-time popular one is: * run last command as root: $ sudo !!

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.

Re: Awesome but commonly unknown Linux Commands

#62

Earlier quoted context omitted.

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

I'd like to hear some justification, cites, or examples for either of these assertions.

I was mis-remembering the "faster" part. It is slower unless you have a version that supports the "-exec {} +" option. However, for security and robustness, see this:

http://stackoverflow.com/questions/896808/find-exec-cmd-vs-x... http://www.gnu.org/software/findutils/manual/html_node/find_...

Re: Awesome but commonly unknown Linux Commands

#63
post #24

All these article links should just end up here: http://www.commandlinefu.com/commands/browse you can sort by date, #(votes) and also search The top all-time popular one is: * run last command as root: $ sudo !!

Check this out -- CommandLineFu One-Liners Explained:

http://www.catonmat.net/blog/top-ten-one-liners-from-command...

Re: Awesome but commonly unknown Linux Commands

#64

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 I use the `say` command.

    make && say "I'm done."

Re: Awesome but commonly unknown Linux Commands

#65

xargs. Too few people know xargs. Every time I see a "find" with "-exec" in it, my soul cries a little bit. (Yes, sometimes it might be necessary, but in the vast majority of cases not.)

And too few people know that GNU Parallel[1] is most of the time a better xargs than xargs itself. [1]: http://www.gnu.org/s/parallel/

How is it different than xargs -P?

Re: Awesome but commonly unknown Linux Commands

#66
post #46

Earlier quoted context omitted.

strace is the Daddy of debugging especially when you can attach it to an already existing program using it's PID. I have solved so many permissions errors problems with strace where the application itself just failed without logging anything.

If the application fails, wouldn't it just shut down and the process ends? Meaning that I can't call strace anymore? Do you have suggestions for that usecase? How would I know what the process id is going to be before I start the program?

$ strace program args

Re: Awesome but commonly unknown Linux Commands

#67
post #4

One I use all the time is this: $ pwd /Users/me/Sites/foo $ pushd . $ cd / $ pwd / $ popd $ pwd /Users/me/Sites/foo Or in English: If you're in a directory that you need to leave but you know you'll go back there in a minute, use "pushd ." to save that directory. Then go off and do whatever you need to, and when you need to return to the saved directory, use "popd" to take you straight back there.

You can also use $CDPATH to jump easily between directories e.g. : Imagine you have this folder ~/dev/python/my_awesome_project If you set CDPATH to '.:~/dev/python', you can easily jump to your project just by doing cd my_awesome_project, it doesn't matter where you actually are in your FS! I use it heavily with cd -, you should give it a try!

I really like $CDPATH, but there are tons of sloppy scripts out there that assume "cd $FOO" has no output and break when $CDPATH is set. Drives me nuts.

Re: Awesome but commonly unknown Linux Commands

#68
post #53

Earlier quoted context omitted.

strace is the Daddy of debugging especially when you can attach it to an already existing program using it's PID. I have solved so many permissions errors problems with strace where the application itself just failed without logging anything.

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/

Re: Awesome but commonly unknown Linux Commands

#69

Earlier quoted context omitted.

And too few people know that GNU Parallel[1] is most of the time a better xargs than xargs itself. [1]: http://www.gnu.org/s/parallel/

How is it different than xargs -P?

http://www.gnu.org/s/parallel/man.html#differences_between_x...

Re: Awesome but commonly unknown Linux Commands

#70

On Linux I very regularly use 'strace', to see what a program is currently doing (in terms of syscalls), what files were opened/read/written/closed, etc.

strace, combined with lsof and netstat can help you with so many things it's not even funny.

I've debugged stalled processes across 3 separate servers with these three tools alone.

Post reply on HN