tar 使用总结
今天需要备份数据,使用tar命令,总结一下。
压缩命令:
tar -zvvf ticket-data-intgration.tar.gz ticket-data-intgration
压缩但是不包含某个文件夹
tar --exclude /home/q/ticket-data-intgration/log --exclude /home/q/ticket-data-intgration/cache -zvvf ticket-data-intgration.tar.gz /home/q/ticket-data-intgration
查看tar包的文件
tar -tzvf ticket-data-intgration.tar.gz
错误:/bin/tar: Removing leading `/' from member names
首先应该明确:linux系统中,使用tar对文件打包时,一般不建议使用绝对路径。使用绝对路径打包时如果不指定相应的参数,tar会产生一句警告信息:”tar: Removing leading `/’ from member names”,并且实际产生的压缩包会将绝对路径转化为相对路径。比如:
root@queen ~ # tar -czvf robin.tar.gz /home/robin
tar: Removing leading `/' from member names
/home/robin/
/home/robin/file1
/home/robin/file2
/home/robin/file3
root@queen ~ # tar -tzvf robin.tar.gz
drwxr-xr-x robin/root -- :: home/robin/
-rw-r--r-- robin/root -- :: home/robin/file1
-rw-r--r-- robin/root -- :: home/robin/file2
-rw-r--r-- robin/root -- :: home/robin/file3
root@queen ~ #
这样的一个压缩包,如果我们再去解开,就会当前目录(也即此例中的“~”)下再新建出“./home/robin/” 两级目录。对于这样的压缩包,解压方法是使用参数 “-C”指解压的目录为根目录(“/”):tar -xzvf robin.tar.gz -C /
更为方便的方法是在打包和解开的时候都使用参数 -P:
root@queen ~ # tar -czvPf robin.tar.gz /home/robin/
/home/robin/
/home/robin/file1
/home/robin/file2
/home/robin/file3
root@queen ~ # tar tzvf robin.tar.gz
drwxr-xr-x robin/root -- :: /home/robin/
-rw-r--r-- robin/root -- :: /home/robin/file1
-rw-r--r-- robin/root -- :: /home/robin/file2
-rw-r--r-- robin/root -- :: /home/robin/file3
root@queen ~ # tar -xzvPf robin.tar.gz
/home/robin/
/home/robin/file1
/home/robin/file2
/home/robin/file3
root@queen ~ #
注意:上面-P的大小写和位置都不能改变
tar 使用总结的更多相关文章
- linux 安装mysql数据库——tar.gz包解压安装法
mysql数据库有多种安装方式,本文只介绍在Linux服务器上的tar.gz包解压安装法, 先通过mysql官网或者网络资源下载 mysql-5.7.3-m13-linux-glibc2.5-x86_ ...
- linux下解压.tar.gz .tar.bz2
从网络上下载到的源码包, 最常见的是 .tar.gz 包, 还有一部分是 .tar.bz2包要解压很简单 :.tar.gz 格式解压命令为 tar -zxvpf x ...
- 压缩和解压文件:tar gzip bzip2 compress(转)
tar[必要参数][选择参数][文件] 压缩:tar -czvf filename.tar.gz targetfile解压:tar -zxvf filename.tar.gz参数说明: -c 建立新的 ...
- centos tar压缩与解压缩命令大全
tar命令详解 -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用 ...
- java关于压缩包的处理,我这里贴出三中格式的(zip,rar,tar)解压方法(目前只用到解压,所以压缩过多研究)。
1.首先我们先来说下为什么会有这三中格式: (1)rar格式:rar格式是最先出现的压缩方式,它主要是用于商业机构一些文件的压缩,它可以根据不同公司的要求,去设定制定不同的压缩算法,这种算法是不对外公 ...
- php php-5.6.4.tar.bz2 apache 兼容问题 child pid 27858 exit signal Segmentation fault
环境 [root envirotar]# uname -a Linux i2..el6.x86_64 # SMP Thu Jul :: UTC x86_64 x86_64 x86_64 GNU/Lin ...
- tar 解压bz2报错 Cannot exec: No such file or directory
tar: bzip2: Cannot exec: No such file or directorytar: Error is not recoverable: exiting now 需要安装bzi ...
- 掌握 tar 命令让你秒变大牛
导读 相信很多初学者在linux环境下为文件归类整理而犯愁,下面是整理文章的的一些命令与技巧,学习Tar命令将会让你处理文件时更加得心应手. Tar(Tape ARchive,磁带归档的缩写:最初设计 ...
- Linux下的压缩和解压缩命令——tar
tar命令 选项: -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只 ...
- linux下tar安装mysql
>>>>>>>>>>>>>>>>>>>> 到官网下载 mysql-5.6.12- ...
随机推荐
- mount.nfs: access denied by server while mounting <SERVER IP>:<SERVER PATH>
root@hipchat:~# mount -t nfs 192.168.10.220:/hipchat/share /home/share/nfs mount.nfs: access denied ...
- python测试开发django-13.操作数据库(增删改查)
前言 django的models模块里面可以新增一张表和字段,通常页面上的数据操作都来源于数据库的增删改查,django如何对msyql数据库增删改查操作呢? 本篇详细讲解django操作mysql数 ...
- 为python安装matplotlib模块
matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,执行python -m pip install - ...
- linux设置允许和禁止访问的IP host.allow 和 host.deny
对于能过xinetd程序启动的网络服务,比如ftp telnet,我们就可以修改/etc/hosts.allow和/etc/hosts.deny的配制,来许可或者拒绝哪些IP.主机.用户可以访问. 比 ...
- Fragment中生命周期函数的介绍
1)第一次启动:onCreate->onAttach->onCreate->onCreateView->onActivityCreated->onStart->on ...
- Chapter 4 -- Throwables
TODO: rewrite with more examples Guava's Throwables utility can frequently simplify dealing with exc ...
- java 常用集合list与Set、Map区别及适用场景总结
转载请备注出自于:http://blog.csdn.net/qq_22118507/article/details/51576319 list与Set.Map区别及 ...
- Springboot 之 自定义配置文件及读取配置文件注意:配置文件中的字符串不要有下划线 .配置中 key不能带下划线,value可以(下划线的坑,坑了我两天..特此纪念)
注意:配置文件中的字符串不要有下划线 .配置中 key不能带下划线,value可以 错误的.不能读取的例子: mySet .ABAP_AS_POOLED = ABAP_AS_WITH_P ...
- Eclipse自定义的透视图如何删除掉?
- JavaScript-手机中访问页面判断
最近在做微信服务号开发,其中遇到一个问题是微信服务号查看的个人的消息,如果点击在浏览器中查看(iOS中是在Safari中打开)应该是跳转到登录页面,因为页面需要从后台获取,因为需要服务端判断,如果是存 ...