Live data from Hacker News

Unix tricks

mmb.pcb.ub.es

111–120 of 232 posts

Re: Unix tricks

#111

tar czf - . | ssh destination "tar xz" To pipe all the contents of your current directory (including dotfiles) to the destination machine. Greetings from LSI-UPC!

Why not rsync?

They're both useful. tar over ssh is very fast for large amounts of data. rsync is only fast if most of the data already exists.

Re: Unix tricks

#112
post #46

tar czf - . | ssh destination "tar xz" To pipe all the contents of your current directory (including dotfiles) to the destination machine. Greetings from LSI-UPC!

I would change this to: tar czf - . | ssh destination "cd /remote/dir; tar xz"

You will one day punch yourself for not being safe.

    tar czf - | ssh destination 'cd /remote/dir && tar xzf -'
Test that `cd` or one day you'll end up extracting in the wrong place.

Re: Unix tricks

#113
- Use 'apt-file' to see which package provides that file you're missing

Ummm, "apt-" isn't a "Unix trick..." It's specific to linux distros which use the "Aptitude" package manager.

Linux != Unix

Re: Unix tricks

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

Re: Unix tricks

#115

Earlier quoted context omitted.

You need a -z to activate compression. But, nonetheless, please always use rsync when copying host to host.

rsync is slow if the data is not already on the destination. tar over ssh is fast, and tar over socketpipe is even faster but not encrypted. I'm not aware of any attributes that tar doesn't preserve.

How so?

Also, I find that if I'm going to copy the data once, I'm often going to copy it twice, or which to get a more up to date version of it at a later time. Rsync clearly wins in these cases.

Finally, from the compress flag on rsync: Note that this option typically achieves better compression ratios than can be achieved by using a compressing remote shell or a compressing transport because it takes advantage of the implicit information in the matching data blocks that are not explicitly sent over the connection.

Re: Unix tricks

#117
post #98
post #85

I freaked out when I found out about the "screen" command several years back. "screen" starts a virtual screen that you can detach from with "ctrl-a d" and you can log out, login from a different machine/session and reattach with "screen -r". it has history so you can run long running commands and reattach 3 days later to continue from where you left off as if you had been logged in the whole time.

Yup! You might want to try tmux, though. I used screen for many years and switched over to tmux about 2 years ago, and have been really happy with it. It (tmux) is also maintained more regularly now; screen development seems to have stagnated. Either way, enjoy!

I will checkout tmux. Thank you!

Re: Unix tricks

#118

* 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

Re: Unix tricks

#119
post #3

> SMB is better than NFS. More details would be nice.

I've found NFS to use much less cpu than SMB (on raspberry pis running XBMC at least)

I third this. I was attempting to set up my Raspberry Pi for sharing a big HDD that was plugged into it on my home network, and the NFS mounts appear to weigh lighter on my vanilla Raspbian setup.

And fwiw, if there's some sort of error with the mount, the terminal lets me know right away.

Re: Unix tricks

#120
zsh: setopt extendedglob allows you to use numeric ranges on globbing with :

mv p1080.jpg folderx/

to move p1080100.jpg through p1080300.jpg to a new folder.

Still not available on bash or more common shells?

Post reply on HN