Live data from Hacker News

Awesome but commonly unknown Linux Commands

anchor.com.au

41–50 of 88 posts

Re: Awesome but commonly unknown Linux Commands

#41

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

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

It is my understanding that -exec is almost always slower, since it generally needs to invoke whatever program you are using many many times more.

Re: Awesome but commonly unknown Linux Commands

#42

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 -…

I just have a script called 'bell': echo -n "\a"

My terminal (urxvt) will detect the bell and set the 'urgent' flag on the window, which is detected by Awesome, which sets the appropriate tag* icon to red.

* Tag in Awesome is more or less akin to a virtual desktop.

Re: Awesome but commonly unknown Linux Commands

#43

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/

Re: Awesome but commonly unknown Linux Commands

#44

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

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

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

Re: Awesome but commonly unknown Linux Commands

#46

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 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?

Re: Awesome but commonly unknown Linux Commands

#47
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.

Re: Awesome but commonly unknown Linux Commands

#48

iftraf sounds interesting. I was looking for just such a program the other day. I was sitting there and noticed with my iStat monitor that I was uploading something at 250 KB/sec. I closed Chrome and eventually all running programs in the doc, yet it still continued. I tried to find out WHAT was uploading that, but to no avail. Any suggestions for tools? I ended up trying iftop, lsof -i, and netstat to get a glimpse,…

Try "nethogs" found it at: http://www.commandlinefu.com/commands/view/2849/triple-monit...

Re: Awesome but commonly unknown Linux Commands

#50
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!

Post reply on HN