tar

云服务器:linux解压压缩命令tar详解

浪尽此生 提交于 2019-12-03 18:04:48
通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具。linux中最流行的tar是麻雀虽小,五脏俱全,功能强大。 tar命令可以为linux的文件和目录创建档案。利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将几个文件组合成为一个文件以便于网络传输是非常有用的。 首先要弄清两个概念:打包和压缩。打包是指将一大堆文件或目录变成一个总的文件;压缩则是将一个大的文件通过一些压缩算法变成一个小文件。 为什么要区分这两个概念呢?这源于Linux中很多压缩程序只能针对一个文件进行压缩,这样当你想要压缩一大堆文件时,56云提醒大家,你得先将这一大堆文件先打成一个包(tar命令),然后再用压缩程序进行压缩(gzip bzip2命令)。linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的。生成tar包后,就可以用其它的程序来进行压缩。 1.命令格式:tar[必要参数][选择参数][文件] 2.命令功能:用来压缩和解压文件。tar本身不具有压缩功能

Linux常用命令

☆樱花仙子☆ 提交于 2019-12-03 17:12:54
系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络适配器及统计 cat /proc/mounts 显示已加载的文件系统 lspci -tv 罗列 PCI 设备 lsusb -tv 显示 USB 设备 date 显示系统日期 cal 2007 显示2007年的日历表 date 041217002007.00 设置日期和时间 - 月日时分年.秒 clock -w 将时间修改保存到 BIOS 关机 (系统的关机、重启以及登出 ) shutdown -h now 关闭系统(1) init 0 关闭系统(2) telinit 0 关闭系统(3) shutdown -h hours

How to untar all .tar.gz with shell-script?

只谈情不闲聊 提交于 2019-12-03 16:25:25
问题 I tried this: DIR=/path/tar/*.gz if [ "$(ls -A $DIR 2> /dev/null)" == "" ]; then echo "not gz" else tar -zxvf /path/tar/*.gz -C /path/tar fi If the folder has one tar, it works. If the folder has many tar, I get an error. How can I do this? I have an idea to run a loop to untar, but I don't know how to solve this problem 回答1: for f in *.tar.gz do tar zxvf "$f" -C /path/tar done 回答2: I find the find exec syntax very useful: find . -name '*.tar.gz' -exec tar -xzvf {} \; {} gets replaced with

Use Maven assembly plugin to set Linux file permissions even when run on other platforms?

余生长醉 提交于 2019-12-03 16:23:29
问题 Similar question: Can Ant's tar task set a Linux file permission even when the task is used on other platforms? If I use Maven 2 assembly plugin with the 'project' descriptor, is there a way to set shell script permissions to executable for example for included build.sh script files? Example: <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2</version> <configuration> <descriptorRefs> <descriptorRef>project</descriptorRef> </descriptorRefs> </configuration> </plugin> This

Python tarfile progress output?

旧街凉风 提交于 2019-12-03 16:18:31
问题 I'm using the following code to extract a tar file: import tarfile tar = tarfile.open("sample.tar.gz") tar.extractall() tar.close() However, I'd like to keep tabs on the progress in the form of which files are being extracted at the moment. How can I do this? EXTRA BONUS POINTS: is it possible to create a percentage of the extraction process as well? I'd like to use that for tkinter to update a progress bar. Thanks! 回答1: Both file-progress and global progress: import io import os import

tar: Error is not recoverable: exiting now

ⅰ亾dé卋堺 提交于 2019-12-03 16:07:04
问题 when I untar doctrine -rw-r--r-- 1 root root 660252 2010-10-16 23:06 Doctrine-1.2.0.tgz I always get this error messages root@X100e:/usr/local/lib/Doctrine/stable# tar -xvzf Doctrine-1.2.0.tgz . . . Doctrine-1.2.0/tests/ViewTestCase.php Doctrine-1.2.0/CHANGELOG gzip: stdin: decompression OK, trailing garbage ignored Doctrine-1.2.0/COPYRIGHT Doctrine-1.2.0/LICENSE tar: Child returned status 2 tar: Error is not recoverable: exiting now The untar operation works, but I always get this error

Issues uncompressing a tar.gz file

独自空忆成欢 提交于 2019-12-03 15:42:01
问题 I have been trying to uncompress the following file: sudo wget http://download.oracle.com/otn-pub/java/jdk/7u21-b11/jdk-7u21-linux-x64.tar.gz with the following: sudo tar zxvf jdk-7u21-linux-x64.tar.gz -C /usr/lib/jvm/ I am getting this error gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now I am using an Amazon Linux instances. By default jre is installed instead of the jdk, which I need to be able to run jboss. I would install the jdk

archiving (ubuntu tar) hidden directories

五迷三道 提交于 2019-12-03 15:30:16
问题 tar on a directory mydir will archive hidden files and hidden subdirectories, but tar from within mydir with a * wildcard will not. Is this a longstanding and known inconsistency or bug? Edit (additional information): tar from within mydir with a wildcard will not "see" nor archive hidden files and hidden subdirectories in the immediate directory. However, in the non-hidden subdirectories of mydir hidden files and hidden subdirectories will be archived. 回答1: With wildcard it will not work.

npm audit Arbitrary File Overwrite

梦想的初衷 提交于 2019-12-03 12:43:06
问题 I recently updated my version of angular using ng update and when running npm audit it found 1 high severity vulnerability but offered no suggestions on how to resolve it. It usually suggests to upgrade a package from package.json like: "angular-devkit/build-angular" but I am already using their latest version. === npm audit security report === Manual Review Some vulnerabilities require your attention to resolve Visit https://go.npm.me/audit-guide for additional guidance High Arbitrary File

Interesting usage of tar… but what is happening?

痞子三分冷 提交于 2019-12-03 11:58:16
I saw the following interesting usage of tar in a co-worker's Bash scripts: `tar cf - * | (cd <dest> ; tar xf - )` Apparently it works much like rsync -av does, but faster. The question arises, how? -m EDIT : Can anyone explain why should this solution be preferable over the following? cp -rfp * dest Is the former faster? On the difference between cp and tar to copy the directory hierarchies, a simple experiment can be conducted to show the difference: alastair box:~/hack/cptest [1134]% mkdir src alastair box:~/hack/cptest [1135]% cd src alastair box:~/hack/cptest/src [1136]% touch foo