* Read on 'ssh-keygen' to avoid typing passwords every time you ssh He meant ssh-agent?
No he did mean ssh-keygen which generates a public and private key pair for you. Run ssh-keygen on your local machine and copy the public key to ~/.ssh/authorized_keys and you'll be able to login to the server without a password using ssh -i /path/to/private/key user@host
Unix tricks
151–160 of 232 posts
Re: Unix tricks
#152Then use fc to get that command back in a vi editing context, change what I want and :wq
The resulting command is immediately executed. This process can be really fast compared to manually constructing long piped commands.
Re: Unix tricks
#153Earlier quoted context omitted.
Better than that for me is "Alt+.", much easier to type. It can be also combined with number like "Alt+2+." will insert second argument. Similarly "Alt+0+." will insert last command. http://linuxcommando.blogspot.in/2009/05/more-on-inserting-a...
If you are on OS X and use Terminal.app “Alt-.” won’t work because Alt is used for alternate characters. You have two options: enable “use option as meta” in the app settings (but you lose the extra characters) or use “Esc-.” instead. Yes, I know about iTerm. I don’t want it.
Re: Unix tricks
#154https://news.ycombinator.com/item?id=5022457
https://news.ycombinator.com/item?id=4481234
A pretty good thread on Reddit:
http://www.reddit.com/r/linux/comments/mi80x/give_me_that_on...
Edit: see https://news.ycombinator.com/item?id=3257393 for a discussion of the above thread.
While we're at it, consider using weborf [1] as an alternative to Python's SimpleHTTPServer for simple file sharing. I found it able to saturate a gigabit ethernet connection when hosted on a Core 2 Duo ULV laptop with an SSD.
[1] See http://galileo.dmi.unict.it/wiki/weborf/doku.php?id=start. It's available from the official repos in Debian and Ubuntu with
sudo apt-get install weborf
Invoking it is dead simple: weborf -b ~/dir-to-shareRe: Unix tricks
#155Re: Unix tricks
#156 /this/is/some/very/nested/directory/
and you need to move to almost the same structure /this/be/some/very/nested/directory/
then you might benefit from function bcd {
cd ${PWD/$1/$2}
}Re: Unix tricks
#157In .inputrc
"\C-p": history-search-backward
"\C-n": history-search-forward
Also I found the following settings to be very useful: # List the possible completions when Tab is pressed
set show-all-if-ambiguous on
#tab complete without needing to get the case right
set completion-ignore-case onRe: Unix tricks
#158His 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/
If security isn't a big consideration (read: you control both machines and the network), you go even faster with netcat. On the receiving machine, in its destination directory: nc -l 6789 | tar xvf - And on the sending machine, from its source directory: tar cvf - . | nc receiving-machine 6789 netcat varies a bit from distro to distro, so you may need to adjust these command lines a bit to get it to work.
Re: Unix tricks
#159Is there a command/short-cut to storing the path(s) returned from a find command? Currently I do something like: find . -name somefile.txt -print Then copy and paste the results manually into a cd command for example. I feel like there's a much better way somewhere.
Here is an example from the man page: >For example, the following command will copy the list of >files and directories which start with > an uppercase letter in the current directory >to destdir:
/bin/ls -1d [A-Z]* | xargs -J % cp -rp % destdir
You can use this with find really nicely.find . -name somefile.txt -print0 | xargs -0 -J % cp -rp % destdir
Note the -print0 and -0 flags (zero). This will use a null byte as a separator instead of spaces to avoid failing on files with spaces in their names.