Commands tagged segmented (1)

  • Mirror a remote directory using some tricks to maximize network speed. lftp:: coolest file transfer tool ever -u: username and password (pwd is merely a placeholder if you have ~/.ssh/id_rsa) -e: execute internal lftp commands set sftp:connect-program: use some specific command instead of plain ssh ssh:: -a -x -T: disable useless things -c arcfour: use the most efficient cipher specification -o Compression=no: disable compression to save CPU mirror: copy remote dir subtree to local dir -v: be verbose (cool progress bar and speed meter, one for each file in parallel) -c: continue interrupted file transfers if possible --loop: repeat mirror until no differences found --use-pget-n=3: transfer each file with 3 independent parallel TCP connections -P 2: transfer 2 files in parallel (totalling 6 TCP connections) sftp://remotehost:22: use sftp protocol on port 22 (you can give any other port if appropriate) You can play with values for --use-pget-n and/or -P to achieve maximum speed depending on the particular network. If the files are compressible removing "-o Compression=n" can be beneficial. Better create an alias for the command. Show Sample Output

    lftp -u user,pwd -e "set sftp:connect-program 'ssh -a -x -T -c arcfour -o Compression=no'; mirror -v -c --loop --use-pget-n=3 -P 2 /remote/dir/ /local/dir/; quit" sftp://remotehost:22
    colemar · 2014-10-17 00:29:34 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

encode HTML entities
Encodes HTML entities from input (file or stdin) so it's possible to directly past the result to a blog or HTML source file.

Using bash inline
There are two ways to use "here documents" with bash to fill stdin: The following example shows use with the "bc" command. a) Using a delimiter at the end of data: $ less-than less-than eeooff bc > k=1024 > m=k*k > g=k*m > g > eeooff 1073741824 b) using the "inline" verion with three less-than symbols: $ less-than less-than less-than "k=1024; m=k*k; g=k*m; g" bc 1073741824 One nice advantage of using the triple less-than version is that the command can easily be recalled from command line history and re-executed. PS: in this "description", I had to use the name "less-than" to represent the less-than symbol because the commandlinefu input text box seems to eat up the real less-than symbols. Odd.

check open ports without netstat or lsof

Octal ls
Do ls with permissions written in octal form.

Install pip with Proxy
Installs pip packages defining a proxy

Using column to format a directory listing
Using column to format a directory listing

Recover remote tar backup with ssh
Here how to recover the remote backup over ssh

Display the number of connections to a MySQL Database
Count the number of active connections to a MySQL database. The MySQL command "show processlist" gives a list of all the active clients. However, by using the processlist table, in the information_schema database, we can sort and count the results within MySQL.

Go to parent directory of filename edited in last command
Uses the last argument of the last executed command, and gets the directory name from it. Use $!:t for the filename alone, without the dirname.

count processes with status "D" uninterruptible sleep

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: