Live data from Hacker News

Awesome but commonly unknown Linux Commands

anchor.com.au

1–10 of 88 posts

Re: Awesome but commonly unknown Linux Commands

#3

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.

Re: Awesome but commonly unknown Linux Commands

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

Re: Awesome but commonly unknown Linux Commands

#5
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 `cd -` to return to the previous directory.

Re: Awesome but commonly unknown Linux Commands

#6
post #5
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 `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.

Re: Awesome but commonly unknown Linux Commands

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

It's really handy for scripts too. pushd/popd definitely live up to the word awesome.

For interactive use zsh has an option called autopushd that automatically pushes directories you `cd` to. I never remember to use pushd so it's a nice convenience.

Re: Awesome but commonly unknown Linux Commands

#10

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.

try austrace. also gdb of course.
Post reply on HN