Earlier quoted context omitted.
$ pushd . $ cd / Why not just $ pushd / ? Also, it's not linux-specific, but bash-specific.
It's not Linux or Bash specific, pushd and popd work on Windows too, and work on network shares, e.g. c:\> pushd \\server\share z:\>
Awesome but commonly unknown Linux Commands
51–60 of 88 posts
Re: Awesome but commonly unknown Linux Commands
#52iftraf 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,…
Re: Awesome but commonly unknown Linux Commands
#53On 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.
For many of the systems applications I design for Illumos, I've used DTrace probes as a way of logging very frequent events, on demand (to avoid frequent IO). All of the events that _must_ be logged for the application to function properly, are logged and fsync'd.
I think that in most systems dynamic tracing will eventually replace a significant portion of the logging functionality that people code into their applications.
Either way, if you think strace is sweet, give DTrace a spin.
Some helpful links:
[0] A video demostration of DTrace, by the creator of DTrace.
[0] http://www.youtube.com/watch?v=6chLw2aodYQ
[1] A post I wrote, demonstrating DTrace. Similar posts can be found on the blog's dtrace-addict page.
[1] http://nickziv.wordpress.com/2011/04/08/adventures-of-a-dtra...
[2] A wiki that contains DTrace examples for various languages and system facilities. Some examples may be Illumos-centric.
[2] http://www.solarisinternals.com/wiki/index.php/DTrace_Topics
[3] DTrace's home. Contains blogs by the engineers behind DTrace.
UPDATE: Meant to reply to parent's parent.
Re: Awesome but commonly unknown Linux Commands
#54xargs. 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.)
I thought find -exec was the preferred way of doing it (better with spaces, not limited in command line length, etc). Why would it be better to use xargs?
xargs is "better" in that it spawns 1 new process for however many things are found. -exec spawns 1 new process for EVERY thing found.
So:
find . -name '*.log' -exec rm {} \;
spawns an rm for every log file. find . -name '*.log' -print0 | xargs -0 rm
spawns 1 rm for MANY log files. (Yes, I know zsh can do stuff like this too.)xargs also has options to limit command line length or # of items if you want to limit that. find -exec is about the same then as find ... | xargs -n1
Re: Awesome but commonly unknown Linux Commands
#55xargs. 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.
Re: Awesome but commonly unknown Linux Commands
#56iftraf 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
#57One 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.
But a few months ago found this.
Re: Awesome but commonly unknown Linux Commands
#58Re: Awesome but commonly unknown Linux Commands
#59If 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 -…
growlnotify -m "Hey I am done!" -t "Done!"Re: Awesome but commonly unknown Linux Commands
#60If 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 -…
make -j3 >make.log 2>&1 ; echo $?
When make finishes, your prompt is printed again (activity!) and the window's caption is highlighted. I use the same mechanism to watch for new mail and chats in other windows. It's like Growl for your terminal.