Linux系统下tar命令,菜鸟提问

作者&投稿:吴奖 (若有异议请与网页底部的电邮联系)
unix 的tar指令~

进入文件所在目录再执行命令
tar -cvzf 压缩文件名.tar.gz 文件1.txt 文件2.txt 文件3.txt
或者给出文件完整路径,是可以创建压缩文件的。

解压到另一个文件夹用命令
tar -zxvf 压缩文件名.tar.gz -C 文件夹路径
比如解压到/home/test目录,就是执行下面的命令
tar -zxvf 压缩文件名.tar.gz -C /home/test

谁让是人家老外开发出来的系统呢,其实大多数命令都是直接按照字母读出来的,比如ls就读l s,我有本《鸟哥的linux私房菜--基础篇》你要的话,给我邮箱我传给你呀。

比如现在在 /A 文件夹下 把下面的B文件夹打包成bzip2高压方式
tar cjvf C.tar.bz2 B # 默认是在当前文件夹下的
OK后会在/A文件夹下有个名为“C.tar.bz2”的tar压缩文件
tar tvf C.tar.bz2 # 列出里面的文件

会用了吧? 呵呵 再把文档粘给你 比较长 别哭哦 学习之路还很远的

TAR(1) tar TAR(1)

NAME
tar - The GNU version of the tar archiving utility

SYNOPSIS
tar <operation> [options]

Operations:
[-]A --catenate --concatenate
[-]c --create
[-]d --diff --compare
[-]r --append
[-]t --list
[-]u --update
[-]x --extract --get
--delete

Common Options:
-C, --directory DIR
-f, --file F
-j, --bzip2
-p, --preserve-permissions
-v, --verbose
-z, --gzip

All Options:
[ --atime-preserve ] [ -b, --blocking-factor N ] [ -B, --read-full-
records ] [ --backup BACKUP-TYPE ] [ --block-compress ] [ -C, --direc-
tory DIR ] [ --check-links ] [ --checkpoint ] [ -f, --file [HOSTNAME:]F
] [ -F, --info-script F --new-volume-script F ] [ --force-local ] [
--format FORMAT ] [ -g, --listed-incremental F ] [ -G, --incremental ]
[ --group GROUP ] [ -h, --dereference ] [ --help ] [ -i, --ignore-zeros
] [ --ignore-case ] [ --ignore-failed-read ] [ --index-file FILE ] [
-j, --bzip2 ] [ -k, --keep-old-files ] [ -K, --starting-file F ] [
--keep-newer-files ] [ -l, --one-file-system ] [ -L, --tape-length N ]
[ -m, --touch, --modification-time ] [ -M, --multi-volume ] [ --mode
PERMISSIONS ] [ -N, --after-date DATE, --newer DATE ] [ --newer-mtime
DATE ] [ --no-anchored ] [ --no-ignore-case ] [ --no-recursion ] [
--no-same-permissions ] [ --no-wildcards ] [ --no-wildcards-match-slash
] [ --null ] [ --numeric-owner ] [ -o, --old-archive, --portabil-
ity, --no-same-owner ] [ -O, --to-stdout ] [ --occurrence NUM ] [
--overwrite ] [ --overwrite-dir ] [ --owner USER ] [ -p, --same-permis-
sions, --preserve-permissions ] [ -P, --absolute-names ] [ --pax-option
KEYWORD-LIST ] [ --posix ] [ --preserve ] [ --acls ] [ --selinux ] [
--xattrs ] [ --no-acls ] [ --no-selinux ] [ --no-xattrs ] [ -R,
--block-number ] [ --record-size SIZE ] [ --recursion ] [ --recursive-
unlink ] [ --remove-files ] [ --rmt-command CMD ] [ --rsh-command CMD ]
[ -s, --same-order, --preserve-order ] [ -S, --sparse ] [ --same-owner
] [ --show-defaults ] [ --show-omitted-dirs ] [ --strip-components NUM-
BER, --strip-path NUMBER (1) ] [ --suffix SUFFIX ] [ -T, --files-from F
] [ --totals ] [ -U, --unlink-first ] [ --use-compress-program PROG ]
[ --utc ] [ -v, --verbose ] [ -V, --label NAME ] [ --version ] [
--volno-file F ] [ -w, --interactive, --confirmation ] [ -W, --verify ]
[ --wildcards ] [ --wildcards-match-slash ] [ --exclude PATTERN ] [ -X,
--exclude-from FILE ] [ -Z, --compress, --uncompress ] [ -z, --gzip,
--gunzip, --ungzip ] [ -[0-7][lmh] ]

(1) tar-1.14 uses --strip-path, tar-1.14.90+ uses --strip-components

DESCRIPTION
This manual page documents the GNU version of tar, an archiving program
designed to store and extract files from an archive file known as a
tarfile. A tarfile may be made on a tape drive, however, it is also
common to write a tarfile to a normal file. The first argument to tar
must be one of the options Acdrtux, followed by any optional functions.
The final arguments to tar are the names of the files or directories
which should be archived. The use of a directory name always implies
that the subdirectories below should be included in the archive.

EXAMPLES
tar -xvf foo.tar
verbosely extract foo.tar

tar -xzf foo.tar.gz
extract gzipped foo.tar.gz

tar -cjf foo.tar.bz2 bar/
create bzipped tar archive of the directory bar called
foo.tar.bz2

tar -xjf foo.tar.bz2 -C bar/
extract bzipped foo.tar.bz2 after changing directory to bar

tar -xzf foo.tar.gz blah.txt
extract the file blah.txt from foo.tar.gz

FUNCTION LETTERS
One of the following options must be used:

-A, --catenate, --concatenate
append tar files to an archive

-c, --create
create a new archive

-d, --diff, --compare
find differences between archive and file system

-r, --append
append files to the end of an archive

-t, --list
list the contents of an archive

-u, --update
only append files that are newer than the existing in archive

-x, --extract, --get
extract files from an archive

--delete
delete from the archive (not for use on mag tapes!)

COMMON OPTIONS
-C, --directory DIR
change to directory DIR

-f, --file [HOSTNAME:]F
use archive file or device F (default "-", meaning stdin/stdout)

-j, --bzip2
filter archive through bzip2, use to decompress .bz2 files

-p, --preserve-permissions
extract all protection information

-v, --verbose
verbosely list files processed

-z, --gzip, --ungzip
filter the archive through gzip

ALL OPTIONS
--atime-preserve
don't change access times on dumped files

-b, --blocking-factor N
block size of Nx512 bytes (default N=20)

-B, --read-full-blocks
reblock as we read (for reading 4.2BSD pipes)

--backup BACKUP-TYPE
backup files instead of deleting them using BACKUP-TYPE simple
or numbered

--block-compress
block the output of compression program for tapes

-C, --directory DIR
change to directory DIR

--check-links
warn if number of hard links to the file on the filesystem mis-
match the number of links recorded in the archive

--checkpoint
print directory names while reading the archive

-f, --file [HOSTNAME:]F
use archive file or device F (default "-", meaning stdin/stdout)

-F, --info-script F --new-volume-script F
run script at end of each tape (implies --multi-volume)

--force-local
archive file is local even if has a colon

--format FORMAT
selects output archive format
v7 - Unix V7
oldgnu - GNU tar <=1.12
gnu - GNU tar 1.13
ustar - POSIX.1-1988
posix - POSIX.1-2001

-g, --listed-incremental F
create/list/extract new GNU-format incremental backup

-G, --incremental
create/list/extract old GNU-format incremental backup

-h, --dereference
don't dump symlinks; dump the files they point to

--help like this manpage, but not as cool

-i, --ignore-zeros
ignore blocks of zeros in archive (normally mean EOF)

--ignore-case
ignore case when excluding files

--ignore-failed-read
don't exit with non-zero status on unreadable files

--index-file FILE
send verbose output to FILE instead of stdout

-j, --bzip2
filter archive through bzip2, use to decompress .bz2 files

-k, --keep-old-files
keep existing files; don't overwrite them from archive

-K, --starting-file F
begin at file F in the archive

--keep-newer-files
do not overwrite files which are newer than the archive

-l, --one-file-system
stay in local file system when creating an archive

-L, --tape-length N
change tapes after writing N*1024 bytes

-m, --touch, --modification-time
don't extract file modified time

-M, --multi-volume
create/list/extract multi-volume archive

--mode PERMISSIONS
apply PERMISSIONS while adding files (see chmod(1))

-N, --after-date DATE, --newer DATE
only store files newer than DATE

--newer-mtime DATE
like --newer, but with a DATE

--no-anchored
match any subsequenceof the name's components with --exclude

--no-ignore-case
use case-sensitive matching with --exclude

--no-recursion
don't recurse into directories

--no-same-permissions
apply user's umask when extracting files instead of recorded
permissions

--no-wildcards
don't use wildcards with --exclude

--no-wildcards-match-slash
wildcards do not match slashes (/) with --exclude

--null --files-from reads null-terminated names, disable --directory

--numeric-owner
always use numbers for user/group names

-o, --old-archive, --portability
like --format=v7; -o exhibits this behavior when creating an
archive (deprecated behavior)

-o, --no-same-owner
do not attempt to restore ownership when extracting; -o exhibits
this behavior when extracting an archive

-O, --to-stdout
extract files to standard output

--occurrence NUM
process only NUM occurrences of each named file; used with
--delete, --diff, --extract, or --list

--overwrite
overwrite existing files and directory metadata when extracting

--overwrite-dir
overwrite directory metadata when extracting

--owner USER
change owner of extraced files to USER

-p, --same-permissions, --preserve-permissions
extract all protection information

-P, --absolute-names
don't strip leading '/'s from file names

--pax-option KEYWORD-LIST
used only with POSIX.1-2001 archives to modify the way tar han-
dles extended header keywords

--posix
like --format=posix

--preserve
like --preserve-permissions --same-order

--acls this option causes tar to store each file's ACLs in the archive.

--selinux
this option causes tar to store each file's SELinux security
context information in the archive.

--xattrs
this option causes tar to store each file's extended attributes
in the archive. This option also enables --acls and--selinux if
they haven't been set already, due to the fact that the data for
those are stored in special xattrs.

--no-acls
This option causes tar not to store each file's ACLs in the
archive and not to extract any ACL information in an archive.

--no-selinux
this option causes tar not to store each file's SELinux security
context information in the archive and not to extract any
SELinux information in an archive.

--no-xattrs
this option causes tar not to store each file's extended
attributes in the archive and not to extract any extended
attributes in an archive. This option also enables --no-acls and
--no-selinux if they haven't been set already.

-R, --record-number
show record number within archive with each message

--record-size SIZE
use SIZE bytes per record when accessing archives

--recursion
recurse into directories

--recursive-unlink
remove existing directories before extracting directories of the
same name

--remove-files
remove files after adding them to the archive

--rmt-command CMD
use CMD instead of the default /usr/sbin/rmt

--rsh-command CMD
use remote CMD instead of rsh(1)

-s, --same-order, --preserve-order
list of names to extract is sorted to match archive

-S, --sparse
handle sparse files efficiently

--same-owner
create extracted files with the same ownership

--show-defaults
display the default options used by tar

--show-omitted-dirs
print directories tar skips while operating on an archive

--strip-components NUMBER, --strip-path NUMBER
strip NUMBER of leading components from file names before
extraction

(1) tar-1.14 uses --strip-path, tar-1.14.90+ uses --strip-compo-
nents

--suffix SUFFIX
use SUFFIX instead of default '~' when backing up files

-T, --files-from F
get names to extract or create from file F

--totals
print total bytes written with --create

-U, --unlink-first
remove existing files before extracting files of the same name

--use-compress-program PROG
access the archive through PROG which is generally a compression
program

--utc display file modification dates in UTC

-v, --verbose
verbosely list files processed

-V, --label NAME
create archive with volume name NAME

--version
print tar program version number

--volno-file F
keep track of which volume of a multi-volume archive its working
in FILE; used with --multi-volume

-w, --interactive, --confirmation
ask for confirmation for every action

-W, --verify
attempt to verify the archive after writing it

--wildcards
use wildcards with --exclude

--wildcards-match-slash
wildcards match slashes (/) with --exclude

--exclude PATTERN
exclude files based upon PATTERN

-X, --exclude-from FILE
exclude files listed in FILE

-Z, --compress, --uncompress
filter the archive through compress

-z, --gzip, --gunzip, --ungzip
filter the archive through gzip

--use-compress-program PROG
filter the archive through PROG (which must accept -d)

-[0-7][lmh]
specify drive and density

BUGS
The GNU folks, in general, abhor man pages, and create info documents
instead. The maintainer of tar falls into this category. Thus this
man page may not be complete, nor current, and was included in the Red
Hat CVS tree because man is a great tool :). This man page was first
taken from Debian Linux and has since been loving updated here.

REPORTING BUGS
Please report bugs via https://bugzilla.redhat.com

SEE ALSO
The full documentation for tar is maintained as a Texinfo manual. If
the info and tar programs are properly installed at your site, the com-
mand

info tar

should give you access to the complete manual.

AUTHORS
Debian Linux http://www.debian.org/
Mike Frysinger <vapier@gentoo.org>

GNU Oct 2004 TAR(1)

这个命令如何使用:
tar cvvf a.tar xx/
意思是把xx文件夹及其内容打包成名为a.tar的文件

打包后的文件默认放在当前目录,也就是你所在的目录

基本命令为:tar cvf tar包名 目录

像你的这个问题其实网上搜一下一大堆,学习linux最主要是自己动手做试验,你问的问题完全可以动手试一下,这样最能记住。
还有记得要善用man命令。

http://baike.baidu.com/view/209679.htm

打包时可以指定路径的


linux系统u盘启动盘linux启动盘u盘
#cat\/usr\/lib\/syslinux\/mbr.bin>\/dev\/sdb#fdisk\/dev\/sdb1ta1因extlinux与syslinux所用的配制文件只是名字不同,内容完全一样,所以可简单的复制一份过来 Fedora怎样安装在U盘,方便携带?准备工作 所需工具\/原料:PowerISO(Linux导入U盘软件)、Fedora-Live-Desktop-x86_64-20-1.iso(系统镜像,大小...

tar后缀是什么文件?
如果tar文件中包含多个文件,则会在解压路径下创建一个与文件名相同的文件夹,并将所有文件解压到该文件夹中。如果只需要解压某个文件,可以在解压之后进入解压后文件夹中找到相应的文件进行操作。tar文件的含义:tar是一种在Unix和Linux操作系统中常见的文件格式,用于将多个文件打包成单个tar文件,以便于...

Linux系统中netstat命令的基本使用方法
深空游戏 向TA提问 关注 展开全部 在计算中,netstat(网络统计数据)是一个命令行工具,它显示传输控制协议的网络连接(传入和传出),路由表,和一个数字网络接口 (网络接口控制器或者软件定义的网络接口)和网络协议的统计数据。它可在类Unix操作系统,包括OS X,Linux,Solaris和BSD,并提供对基于Windows NT的操作系统...

Linux下搭建求生之路2(l4d2)服务器的教程补充(细节点-小白专供)_百度知...
大体上,这位大佬的教程已经非常完善了, 建议先通读TA的文章 ,再通读这篇。我增补一些这篇文章未提到但是有点让人抓狂的细节点。相信仔细阅读他的文章和我的文章,任何新手都能很从容的在linux下搭建属于自己的求生之路2服务器。 众所周知,linux服务器比windows服务器有更稳定和更安全的特点,而且...

请问下面关于linux awk的语句是什么意思呢
info="it is a test" 将it is a test赋给变量info tlen=split(info,tA," ") 将info变量,也就是"it is a test" ,用空格作为分隔符,赋给数组tA, 那么tA就是“it" "is" "a" "test"这四个字符串 for(k=1;k<=tlen;k++){print k,tA[k];} 循环打印出数组tA,结果是:...

linux 的 vixta 如何安装
下载iso,刻盘安装.虚拟机安装的话直接加载iso就可以了.有中文支持吗?我用ubuntu,很好用.iso的镜像有引导功能,你虚拟机加载镜像后,重启虚拟机应该就可以安装了.

虚拟机中的linux怎么进入命令方式
在桌面右击即可进入终端 评论 | 分享 2011-06-02 18:38 king_卫 | 二级 虚拟机啊 虚拟机的话要改一下你虚拟机的热键 才能用crlt + shift +f1-6 你在图形界面下打开终端 init 3就行了 或者是你更改一下etc\/initta缺省值改为3 然后重启 评论 | 分享 知道日报 全部文章 登录...

Linux网络相关配置
2022-07-17 · TA获得超过204个赞 知道小有建树答主 回答量:111 采纳率:57% 帮助的人:35.5万 我也去答题访问个人页 展开全部 这里说的网络配置主要是centos环境 centOS系统,在\/etc\/sysconfig\/network-scripts目录下找到当前机器的端口文件,文件名通常是ifcfg-网络连接名。 vim 打开编辑,添加修改分配模...

linux下如何查看某个网卡当前使用的IP。
2022-11-16 · TA获得超过4958个赞 知道顶级答主 回答量:27.3万 采纳率:100% 帮助的人:240万 我也去答题访问个人页 展开全部 1、连接上相应的linux主机,进入到等待输入shell指令的linux命令行状态下。 2、在linux命令行下输入shell指令:ip addr eth0。 3、键盘按“回车键”运行shell指令,此时会查...

虚拟机中的linux怎么进入命令方式
虚拟机安装Linux开启进入系统后,常用的有3种进入终端命令(terminal)界面方法,分别如下:①按快捷键“Ctrl+Alt+T”即可打开终端窗口;②或者按“Ctrl+Alt+F1-F6”均可进入终端(模拟终端,不显示桌面);③直接搜索“终端”并进入。

古塔区18283515222: 如何在Linux上使用tar命令解压和压缩文件 -
子丰徐雷卡: Linux系统压缩和解压文件都可以用tar命令,在压缩文件时指定压缩参数,解压缩时指定解压参数. tar命令主要参数解释: -z参数:表示要解压或压缩的是tar.gz文件(如果是tar.bz2就是-j) -x参数:表示是执行解压缩操作而不是打包操作 -v参数...

古塔区18283515222: Linux中tar的命令
子丰徐雷卡: 举个例子来说吧. 如果已经存在用户rehdat, 文件/root/filetext.tar(这种格式只是单纯的打包,当然权限是只有root才能读写). [root@redhat ~]# tar -xf filetext.tar -C /home/redhat/ [root@redhat ~]# tar -zxf filetext.tar.gz -C /home/redhat/ (对使用...

古塔区18283515222: linux 打包命令 tar 的几个用法 -
子丰徐雷卡: 1)tar -r 可以append file to tared_package. tar -rf tared_package 添加文件 2)不打包目录用 ls -a --color=none | grep -v '^\.*$' | xargs tar -zcvf Workspace.tar.gz --exclude 目录名 3) 删除用 tar --delete -f tared_package 删除文件名

古塔区18283515222: linux 中tar 命令,菜鸟级问题~ -
子丰徐雷卡: 看起来貌似没有问题.但是把“/”去掉肯定不行啊.根目录都没有了怎么搞.就我知道的,一般对于tar包有两种语法方式.举个例子,就你的文件夹来说,我在/home/jie 有个Desktop文件,大包成test.tar.那么,1.如果光大包不压缩,则为:tar -cvf test.tar /home/jie/Desktop/2.打包后,以dzip压缩.那么:tar -zcvf test.tar.gz /home/jie/Desktop 我现在身边没有LINUX虚拟机,好久没用,忘记了.那么你再试试打包的时候加上路径试试呢?比如写成/home/test.tar.不好意思,忘记了.要是来得及,等我过两天回去试试

古塔区18283515222: linux系统的tar命令.
子丰徐雷卡: 你好! 这是因为你命令后面缺少了要打包的文件路径,所以会提示“空归档文件”. 你可以修改为以下即可: tar -cf cdkk123.tar /home/cdkk 另外建议下LANG最好不要设置成zh_CN,其实英文状态更利于对Ubuntu的学习及问题处理. 如果能够帮助你解决此问题,那么希望你点击“采纳”, 举手之劳,将鼓励我们继续解答其他网友的疑问,(□影□子㊣)谢谢!

古塔区18283515222: linux下怎样使用tar命令解压缩名称中不包括“ - ”字符的其他压缩文件 -
子丰徐雷卡: linux中,如何使用tar进行解压缩环境:windows 7 + virtualboax + fedora 15 kde可以使用tar命令解压缩.tar.gz文件,下面以解压缩qt源文件举例:1.在windows中将qt源文件拷贝到共享文件夹下2.在fedora 15中,进入到共享文件下,共享文件会自...

古塔区18283515222: Windows 中压缩包tar 在Linux中如何使用? -
子丰徐雷卡: 1.确认当前LINUX系统中安装了gcc编译器环境,可以使用rpm -qa | grep gcc来查看一下2.获得程序的源代码安装包文件(你已经获得了,只需要挂载上就可以了)3.释放你的源代码安装包文件(使用命令:tar xzf rarlinux-3.6.0.tar.gz)4.进入你的源代码文件所在的目录(cd /home/你的用户名/download/rarlinux-3.6.0)5.进行编译前的配置:./configure --prefix=程序安装的绝对路径6.使用make命令进行程序的二进制编译(直接输入make)7.输入:make install命令安装你的程序8.你现在可以大喊一声:哦!耶!开始使用程序

古塔区18283515222: linux中的tar命令
子丰徐雷卡: 可以看看tar的man页,上面说得很清楚了(看英文的man页,中文的已经过时了,好多地方不对). 对于tar命令,x表示解包(不是解压缩),v表示显示详细过程,f表示使用文件(紧跟它的一定是空格加文件名),z表示先解压gzip格式的压缩...

古塔区18283515222: linux中的“tar命令”怎么解压“.tgz”与“.tar.gz”文件? -
子丰徐雷卡: 1.压缩命令: 命令格式:tar -zcvf 压缩文件名.tar.gz 被压缩文件名 可先切换到当前目录下.压缩文件名和被压缩文件名都可加入路径.2.解压缩命令: 命令格式:tar -zxvf 压缩文件名.tar.gz 解压缩后的文件只能放在当前的目录. 3.Linux下如何解...

古塔区18283515222: linux下自带tar命令么?我要用这个命令需要安装别的什么么? -
子丰徐雷卡: linux自带了tar命令, 想要知道它的用法的话, 可能输入 man tar 或者直接在网上查它的用法, 一般情况下tar只是用一打包的, 如果还要压缩的话, 还要配合gzip或bzip2, 可能通过参数来指定, 建议你去鸟哥的linux私房菜查询常用指令的具体用法, 私房菜有一个专门的网站

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网