Live data from Hacker News

Unix tricks

mmb.pcb.ub.es

51–60 of 232 posts

Re: Unix tricks

#51
post #20

The special bash command I'm most often asked about by shoulder surfers is !$. It substitutes the last argument in the previous command into the current one. For example: $ ls /some/long/path/somewhere/looking/around/ $ cd !$ cd /some/long/path/somewhere/looking/around/

I like that one and `!!` for the inevitable point I've forgotten to put sudo in before a command.

Re: Unix tricks

#52
Instead of

    ProxyCommand ssh -T host1 'nc %h %p'
you can use

    ProxyCommand ssh -W %h:%p host1
which uses ssh itself and therefor also works on machines where netcat isn't installed.

Re: Unix tricks

#53
Weird, I've been using vi/elvis/vim/MacVim as my primary editor since 1984 and I hate vi key bindings for shell; I always use the emacs bindings.

Re: Unix tricks

#54
If I may add a trick:

ctrl-z - stops a program

bg - sends the stopped program to the background

fg - gets the program back to the foreground (interactive mode)

very useful in editor sessions or when you want to get rid of the endless download/scp that is blocking your terminal

Re: Unix tricks

#55
His last trick - compressed fie transfer without intermediate state:

  'tar cz folder/ | ssh server "tar xz"'
Can be pulled off with two flags to scp - and you get to see progress as a benefit!

  scp -Cr folder server:dest/

Re: Unix tricks

#56

Weird, I've been using vi/elvis/vim/MacVim as my primary editor since 1984 and I hate vi key bindings for shell; I always use the emacs bindings.

I'm the opposite. Every time I log into a server that doesn't have my bashrc, I immediately have to `set -o vi` or else I'm useless.

Re: Unix tricks

#57
post #54

If I may add a trick: ctrl-z - stops a program bg - sends the stopped program to the background fg - gets the program back to the foreground (interactive mode) very useful in editor sessions or when you want to get rid of the endless download/scp that is blocking your terminal

You can also use "jobs" to see background and stopped tasks. If there are multiple jobs, you can use "fg 2" to foreground the second job on the list, etc.

Re: Unix tricks

#58
Here's one it took me a while to figure out...

Hung SSH session (such as wifi out of range)?

Type Return-Tilde-Period

Re: Unix tricks

#60

Whut? ctrl-r? How have I missed that? No more 'history|grep foo' for me!

If you are using 'set -o vi', then you can just use 'ESC' -> '/' then use 'n' to iterate in reverse order through the commands that match the vi regex. really powerful and useful.
Post reply on HN