tar

常用linux系统命令-压缩命令

杀马特。学长 韩版系。学妹 提交于 2019-12-04 23:42:02
###zip(保留原文件) 不能压缩文件夹 zip file.zip file1 file2 压缩文件 unzip file.zip 解压压缩文件 ###tar(不保留原文件) tar -cjf file.tar.bz2 file1 file2 压缩 tar -czf file.tar.gz file1 file2 压缩 tar -xvf 解压(通用) 来源: https://www.cnblogs.com/chenlulu1122/p/11888597.html

文件夹备份tar脚本

孤人 提交于 2019-12-04 23:17:40
#! /bin/sh SOURCEDIR=/data/OA DESTDIR=/data/OAbackup TARDIR=/data/gz #拷贝源文件夹至目标文件夹 cp -r $SOURCEDIR $DESTDIR #tar压缩 tar -zcPvf $TARDIR/backup$(date +%Y%m%d%H%M).tar.gz $DESTDIR #删除临时文件夹内容 cd $DESTDIR rm -rf $DESTDIR/* #删除mtime修改时间超过3天的文件 cd /data/gz find $TARDIR/ -mtime +3 -name "*.tar.gz" -exec rm -rf {} \; 来源: https://www.cnblogs.com/kylingx/p/11887731.html

Extract files contained in archive.tar.gz to new directory named archive

谁都会走 提交于 2019-12-04 22:21:01
I have a directory containing about 800 .tgz archives, each containing about 10 files. Effectively, I want to convert each archive into a directory of the same name. Is there a simple one line command to do this, or should I write a script? I think you will need to script this. You can specify the directory that the extract is placed in by using the tar -C option. The script below assumes that the directories do not exist and must be created. If the directories do exist the script will still work - the mkdir will simply fail. tar -xvzf archive.tar.gx -C archive_dir e.g. for a in *.tar.gz do a

Linux 解压命令大全

无人久伴 提交于 2019-12-04 21:41:42
.tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩:gzip FileName .tar.gz 和 .tgz 解压:tar zxvf FileName.tar.gz 压缩:tar zcvf FileName.tar.gz DirName ——————————————— .bz2 解压1:bzip2 -d FileName.bz2 解压2:bunzip2 FileName.bz2 压缩: bzip2 -z FileName .tar.bz2 解压:tar jxvf FileName.tar.bz2 压缩:tar jcvf FileName.tar.bz2 DirName ——————————————— .bz 解压1:bzip2 -d FileName.bz 解压2:bunzip2 FileName.bz 压缩:未知 .tar.bz 解压:tar jxvf FileName.tar.bz 压缩:未知 ——————————————— .Z 解压:uncompress FileName.Z 压缩:compress FileName .tar.Z

why doesn't tar preserve file permissions? [closed]

随声附和 提交于 2019-12-04 19:13:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have noticed that a tarball created on one linux does not preserve the file permissions when extracted on another linux. How can I make tar preserve the file permissions? 回答1: Use the p option, both when creating the tarball and when extracting it. 回答2: Can you try: tar -pcvzf xxx.tar.gz p == preserve

红帽学习笔记[RHCSA] 第二周

早过忘川 提交于 2019-12-04 18:48:53
目录 红帽学习笔记[RHCSA]第二周 环境 第七课[网络配置相关] 在Vmware中添加网卡 将网卡添加到虚拟机上 关于网卡命名规则 配置网络 网络配置命令总结 更改hostname 关于SSH的一些配置 远程复制文件 SCP 关于init(在7中已经不用了) 第八课 nice值 调整时间 安装软件包 使用yum 安装软件包 第九课 文件归档 硬盘 分区创建、使用 分区自动挂载 Swap虚拟内存 软连接与硬链接 第十课 计划任务[At & Cron Jobs] 逻辑卷管理 十一课 文件特殊权限 facl Selinux 红帽学习笔记[RHCSA]第二周 环境 rhel-server-7.0-x86_64-dvd.iso 镜像 VMware-workstation 第七课[网络配置相关] 在Vmware中添加网卡 编辑 -> 编辑虚拟网络 -> 添加网络 -> 随便选择一个如VMnet2 -> 选择仅主机模式 -> 勾掉 使用本地DHCP服务将ip分给虚拟机 -> 子网Ip默认就行 注: ​ 1. win10 用户需要管理源权限,否则都是灰的添加不了,点击重启就好 ​ 2. Wmnet1,WMnet8是WMware默认的网卡 # 打开 windows CMD # 会看到如下的网卡信息 C:\Users\kanewang>ipconfig Ethernet adapter

Tar only the Directory structure

≡放荡痞女 提交于 2019-12-04 18:45:10
问题 I want to copy my directory structure excluding the files. Is there any option in the tar to ignore all files and copy only the Directories recursively. 回答1: You can use find to get the directories and then tar them: find .. -type d -print0 | xargs -0 tar cf dirstructure.tar --no-recursion If you have more than about 10000 directories use the following to work around xargs limits: find . -type d -print0 | tar cf dirstructure.tar --no-recursion --null --files-from - 回答2: Directory names that

软件管理

折月煮酒 提交于 2019-12-04 17:27:35
软件管理 RPM软件包管理 源码包管理 压缩与解压缩 linux software manager 一.RPM软件包 适用于redhat redflag centos suse 1)rpm 命令 rpm -ivh 1 i 安装 2 v 显示安装过程 3 h hash [Use with -v|--verbose for a nicer display.] 4 q 查找 查询 5 -qf 查看某个文件时属于哪个软件包 6 -qi 查看软件包的信息【出厂信息】 7 -qa 查找已安装所有匹配XXX关键字的软件包 8 -e 卸载rpm软件包 9 -ql 查看软件包包含哪些文件 10 -U 升级软件包 思考问题 依赖问题 —nodeps 软包安装不完整 重新安装 —replacepkgs —force 2)YUM 安装 YUM C/S架构 1 YUM源服务器 [共享所有软件包] 通过文件服务器 【http ftp file】 2 YUM客户端 3 YUM客户端配置文件设置 YUM 客户端配置文件 /etc/yum.repos.d/ 配置文件名字两部分组成 *.repo 前半部分可以随便写 后半部分必须是repo 1 [baism] 2 name=www.ayitula.com 3 baseurl=ftp://192.168.10.253/pub 4 enabled=1 5 gpgcheck

tar exclude single files/directories, not patterns

廉价感情. 提交于 2019-12-04 15:45:27
问题 I'm using tar to make daily backups of a server and want to avoid backup of /proc and /sys system directories, but without excluding any directories named "proc" or "sys" somewhere else in the file tree. For, example having the following directory tree (" bla " being normal files): # find . ./sys ./sys/bla ./foo ./foo/sys ./foo/sys/bla I would like to exclude ./sys but not ./foo/sys . I can't seem to find an --exclude pattern that does that... # tar cvf /dev/null * --exclude=sys foo/ or... #

Docker volume: backup

此生再无相见时 提交于 2019-12-04 14:55:40
I have created a volume container. And a container which mounts to en from the volume container. Volume container: docker run -d --name nexus-data nexus:1.0 echo "data-only container for Nexus" My Nexus container: docker run -d -p 8443:8443 -p 8081:8081 --name nexus --restart=always --volumes-from nexus-data nexus:1.0 So this is working fine. I'm able to delete and recreate my nexus-container without losing data. The volume container (which isn't in running state) is saving the data. But the bottleneck of this approach is the volume-container. When I accidentally delete this container, all the