notes
- 注意scp
指定端口号时是大写的P
ref
- 断点续传可以用rsync
ssh -p portnumber username@ip
# download: remote -> local
scp -P portnumber user@remote_host:remote_file local_file
# upload: local -> remote
scp -P portnumber local_file user@remote_host:remote_file
# 断点续传
rsync -P -e ssh local_file ssh_host_name:/remote_file
# ssh_host_name的配置参见下面的【ssh免秘钥,免ip登录】
scp 单次传输多个文件 参考
scp -T username@ip.of.server.copyfrom:“file1.txt file2.txt” “~/yourpathtocopy”
# 只需输一次密码
scp username@ip.of.server.copyfrom:"file1.txt file2.txt" "~/yourpathtocopy"
Linux压缩与解压文件参考
# compress file or directory
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
# Compress Multiple Directories or Files at Once
tar -czvf archive.tar.gz /home/ubuntu/Downloads /usr/local/stuff /home/ubuntu/Documents/notes.txt
# Exclude Directories and Files
tar -czvf archive.tar.gz /home/ubuntu --exclude=/home/ubuntu/Downloads --exclude=/home/ubuntu/.cache
tar -czvf archive.tar.gz /home/ubuntu --exclude=*.mp4
# using bzip2
tar -cjvf archive.tar.bz2 stuff
# Extract an Archive
tar -xzvf archive.tar.gz
While
gzip
compression is most frequently used to create.tar.gz
or.tgz
files, tar also supportsbzip2
compression. This allows you to create bzip2-compressed files, often named.tar.bz2
,.tar.bz
, or.tbz
files. To do so, just replace the-z
forgzip
in the commands here with a-j
forbzip2
.
Gzip is faster, but it generally compresses a bit less, so you get a somewhat larger file.
Bzip2 is slower, but it compresses a bit more, so you get a somewhat smaller file. Gzip is also more common, with some stripped-down Linux systems including gzip support by default, but not bzip2 support. In general, though, gzip and bzip2 are practically the same thing and both will work similarly.
Name | Speed | size | suffix | cmd |
---|---|---|---|---|
Gzip | faster | larger | .tar.gz ,.tar.bz | -z |
Bzip2 | slower | smaller | .tar.bz2 , .tar.bz | -j |