2021-05-12 14:32:11
Linux基礎教學學習筆記12——壓縮、歸檔和系統間的檔案傳輸
Linux基礎教學學習筆記12——壓縮、歸檔和系統間的檔案傳輸
一、歸檔和壓縮
歸檔:archive
tar命令歸檔的常用選項:
[root@linuxidc ~]# tar --helpExamples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely. 列出歸檔檔案中的檔案
tar -xf archive.tar # Extract all files from archive.tar.
Main operation mode:
-A, --catenate, --concatenate append tar files to an archive 追加檔案到一個歸檔檔案
-c, --create create a new archive 建立一個歸檔檔案
-r, --append append files to the end of an archive 將檔案追加到歸檔檔案的結尾
-t, --list list the contents of an archive 列出歸檔檔案的內容
-u, --update only append files newer than copy in archive 只歸檔比歸檔檔案更新的檔案
-x, --extract, --get extract files from an archive 解壓歸檔檔案
-C, --directory=DIR change to directory DIR 制定歸檔或解歸檔的路徑
--remove-files remove files after adding them to the archive 歸檔完成之後刪除原檔案
壓縮:compress
tar命令壓縮的常用選項:
Compression options:
filter through PROG (must accept -d)
-j, --bzip2 filter the archive through bzip2
-J, --xz filter the archive through xz
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
-Z, --compress, --uncompress filter the archive through compress
[root@linuxidc tmp]# tar jcvf aa.bz2 aa
[root@linuxidc tmp]# tar zcvf aa.gz aa
[root@linuxidc tmp]# tar jxvf aa.bz2 /opt/
[root@linuxidc tmp]# tar zxvf aa.gz /opt/
cpio命令歸檔壓縮rpm安裝檔案
cpio的常用選項:
[root@linuxidc tmp]# cpio --help
Examples:
# Copy files named in name-list to the archive
cpio -o < name-list [> archive]
# Extract files from the archive
cpio -i [< archive]
# Copy files named in name-list to destination-directory
cpio -p destination-directory < name-list
Main operation mode:
-i, --extract Extract files from an archive (run in copy-in
mode)
-o, --create Create the archive (run in copy-out mode)
-p, --pass-through Run in copy-pass mode
-t, --list Print a table of contents of the input
rpm安裝包的本質是一個壓縮包,安裝rpm包相當於將壓縮的檔案解壓縮到對應的資料夾:
[root@linuxidc xx]# rpm2cpio ../vsftpd-3.0.2-9.el7.x86_64.rpm |cpio -id
707 blocks
[root@linuxidc xx]# ls
etc usr var xx1 xx2
二、系統間的檔案傳輸
scp需要依賴於openssh-client:
scp,本地或者遠端的檔案互相拷貝,拷貝目錄加-r選項:
[root@linuxidc ~]# scp --help
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2
[root@linuxidc ~]# scp -r /tmp root@192.168.100.1:~/xx
rsnc:
[root@linuxidc ~]# rsync --help
Usage: rsync [OPTION]... SRC [SRC]...
DEST
or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
or rsync [OPTION]... [USER@]HOST:SRC [DEST]
or rsync [OPTION]... [USER@]HOST::SRC [DEST]
or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.
Options
-v, --verbose increase verbosity
-q, --quiet suppress non-error messages
--no-motd suppress daemon-mode MOTD (see manpage caveat)
-c, --checksum skip based on checksum, not mod-time & size
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories
-R, --relative use relative path names
--no-implied-dirs don't send implied dirs with --relative
-b, --backup make backups (see --suffix & --backup-dir)
--backup-dir=DIR make backups into hierarchy based in DIR
--suffix=SUFFIX set backup suffix (default ~ w/o --backup-dir)
-u, --update skip files that are newer on the receiver
--inplace update destination files in-place (SEE MAN PAGE)
--append append data onto shorter files
--append-verify like --append, but with old data in file checksum
-d, --dirs transfer directories without recursing
windows系統與linux系統間檔案的拖拉直接傳輸,可以安裝lrzsz.x86_64這個包
Xshell終端可以直接輸入rz命令,進行檔案的傳輸
linux拷貝到windows使用sz file
Xshell直接按快捷鍵crtl+alt+F鍵呼叫xftp進行大檔案傳輸;
本文永久更新連結地址:http://www.linuxidc.com/Linux/2015-03/114940.htm
相關文章