tar

Linux中的文件查找和压缩

匿名 (未验证) 提交于 2019-12-02 21:56:30
文件查找 在文件系统上查找符合条件的文件 文件查找:locate, find 非实时查找(数据库查找):locate 实时查找:find locate 查询系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 依赖于事先构建的索引 索引的构建是在系统较为空闲时自动进行(周期性任务),管理员手动更新数据库 (updatedb) 索引构建过程需要遍历整个根文件系统,极消耗资源 工作特点: locate KEYWORD 有用的选项 -i 不区分大小写的搜索 -n N 只列举前N个匹配项目 -r 使用基本正则表达式 示例 搜索名称或路径中带有“conf”的文件 locate conf 使用Regex来搜索以“.conf”结尾的文件 locate -r ‘.conf$’ find 实时查找工具,通过遍历指定路径完成文件查找 工作特点: 语法:find [OPTION]... [查找路径] [查找条件] [处理动作] 查找路径:指定具体目标路径;默认为当前目录 查找条件:指定的查找标准,可以文件名、大小、类型、权限等标准进行; 默认为找出指定路径下的所有文件 处理动作:对符合条件的文件做操作,默认输出至屏幕 查找条件 指搜索层级 -maxdepth level 最大搜索目录深度,指定目录为第1级 -mindepth level 最小搜索目录深度 先处理目录内的文件

linux压缩和解压缩命令大全

匿名 (未验证) 提交于 2019-12-02 21:56:30
tar命令   解包:tar zxvf FileName.tar   打包:tar czvf FileName.tar DirName 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   解压:tar Zxvf FileName.tar.Z   压缩:tar

Linux服务器系统备份还原

匿名 (未验证) 提交于 2019-12-02 21:53:52
利用tar指令对linux系统下面的文件打包成为一个压缩文件。 tar -cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys --exclude=/media / 利用scp命令进行不同服务器间数据拷贝传输,只需在备份端输入SCP指令就能把备份传到需要还原的vps上: scp -P 22 -r /替换成源目录/ root@B服务器IP地址:/替换成目的目录/ 其中端口号22,和服务器地址,源目录和目的目录需要按实际情况更改。 也是需要tar指令就能还原系统: tar -xvpzf backup.tgz -C /

Linux编程 8 (挂载mount,查看磁盘df du,搜索grep,压缩zgip,归档tar)

匿名 (未验证) 提交于 2019-12-02 21:53:52
一. 挂载存储媒体   linux文件系统将所有的磁盘都并入一个虚拟目录下,当使用新的存储媒体之前,需要把它放到虚拟目录下,这项工作称为挂载(mounting)    1.1 mount 命令     在linux上用来挂载媒体的命令叫做mount. 默认情况下,mount命令会输出当前系统上的挂载的设备列表。    1.2 umont     要除移可移动设备时,不能直接从系统上移除,应该先卸载。使用umont命令(以后在演示)。 二. 查看磁盘空间    在linux系统中,监测系统磁盘使用情况很重要。知道还有多少空间供程序使用。下面介绍磁盘管理常用的命令。    2.1 df 命令     使用df -h参数会输出系统磁盘空间信息,已易读形式显示,如下图所示:           2.2 du 命令     使用du -h命令将显示当前目录的磁盘使用情况,确定占用了多少存储空间,是否有超大文件。如下图所示,显示mysql 的数据目录磁盘占用情况。        三 数据处理    3.1 搜索数据 grep     在前面章节介绍ps 命令查看进程时有说过grep命令。下面演示在mysql错误日志文件中,找出含有Warning关键词的信息。如下图所示:            使用grep -c参数显示匹配数,下面匹配Warning关键词数有50个。如下图所示 :       

linux定时任务及练习

匿名 (未验证) 提交于 2019-12-02 21:53:52
第1章 定时任务 1.1 什么是定时任务 相当于闹钟每天叫你起床 设定一个时间去做某件事 1.2 系统定时任务 [root@zeq ~]# ll -d /etc/cron* drwxr-xr-x. 2 root root 4096 Jul 10 18:24 /etc/cron.d drwxr-xr-x. 2 root root 4096 Jul 10 18:24 /etc/cron.daily 系统定时任务每天运行这个目录里的内容 drwxr-xr-x. 2 root root 4096 Jul 10 18:23 /etc/cron.hourly 系统定时任务每小时运行这个目录里的内容 drwxr-xr-x. 2 root root 4096 Jul 10 18:24 /etc/cron.monthly 系统定时任务每月运行这个目录里的内容 drwxr-xr-x. 2 root root 4096 Sep 27 2011 /etc/cron.weekly 系统定时任务每周运行这个目录里的内容 -rw-------. 1 root root 0 Aug 24 2016 /etc/cron.deny 系统定时任务的黑名单 -rw-r--r--. 1 root root 457 Sep 27 2011 /etc/crontab 系统定时任务的配置文件之一 系统定时任务日志切割 [root

How can I untar a tar.bz file in unix?

妖精的绣舞 提交于 2019-12-02 21:51:42
I've found tons of pages saying how to untar tar.bz2 files, but how would one untar a tar.bz file? use the -j option of tar . tar -xjf /path/to/archive.tar.bz According to the man pages for bzip2 If the file does not end in one of the recognised endings, .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot guess the name of the original file, and uses the original name with .out appended. Based on this, I'm guessing that '.bz' is considered a valid suffix for bzip2 compressed files. Also, keep in mind that the original file name was probably generated by hand, something like this: tar jcf

How do I exclude absolute paths for tar?

喜夏-厌秋 提交于 2019-12-02 21:48:05
I am running a PHP script that gets me the absolute paths of files I want to tar up. This is the syntax I have: tar -cf tarname.tar -C /www/path/path/file1.txt /www/path/path2/path3/file2.xls When I untar it, it creates the absolute path to the files. How do I get just /path with everything under it to show? If you want to remove the first n leading components of the file name, you need strip-components . So in your case, on extraction, do tar xvf tarname.tar --strip-components=2 The man page has a list of tar 's many options, including this one. Some earlier versions of tar use --strip-path

Linux基础(三)

一个人想着一个人 提交于 2019-12-02 21:39:59
目录 解压缩的命令 搭建测试环境 解压缩的命令 Windows:zip和rar Linux:zip、tar、tar.gz zip包 (如果命令没找到,则需要连接外网手动安装zip: yum -y install zip unzip ) 打包:zip -r zip -r sum.zip aaa a.txt b.txt c.txt 解包:unzip unzip sum.zip tar包 打包:tar -cvf tar -cvf sum.tar aaa a.txt b.txt c.txt 解包:tar -xvf tar -xvf sum.tar tar.gz包 打包+压缩:tar -zcvf tar -zcvf all.tar.gz aaa a.txt sum.zip sum.rar 解包+解压:tar -zxvf tar -zxvf all.tar.gz rmp相当于exe(windows中的安装包) 搭建测试环境 项目环境: 开发环境 生产环境 测试环境 硬件环境: web服务器:cpu:intel i7,8G内存,金士顿1T固态硬盘,万兆网卡 数据库服务器:cpu:intel i7,8G内存,金士顿1T固态硬盘,万兆网卡 软件环境:(Java) JDK1.8 + TOMCAT8.0 + MYSQL5.7/Oracle11g 1、安装JDK1.8 1.下载并上传到 /opt

Golang read from pipe reads tons of data

强颜欢笑 提交于 2019-12-02 20:55:33
I'm trying to read an archive that's being tarred, streaming, to stdin, but I'm somehow reading far more data in the pipe than tar is sending. I run my command like this: tar -cf - somefolder | ./my-go-binary The source code is like this: package main import ( "bufio" "io" "log" "os" ) // Read from standard input func main() { reader := bufio.NewReader(os.Stdin) // Read all data from stdin, processing subsequent reads as chunks. parts := 0 for { parts++ data := make([]byte, 4<<20) // Read 4MB at a time _, err := reader.Read(data) if err == io.EOF { break } else if err != nil { log.Fatalf(

programmatically extract tar.gz in a single step (on windows with 7zip)

偶尔善良 提交于 2019-12-02 20:10:43
PROBLEM: I would like to be able to extract tar.gz files in a single step. This makes my question almost identical to this one: stackoverflow question for tar-gz . My question is almost the same, but not the same, because I would like to do this on windows using 7zip command-line (or something similar) inside a bat file or ruby/perl/python script. QUESTION: This seemingly simple task is proving to be more involved than the first appearance would make it out to be. Does anyone have a script that does this already? 7z e example.tar.gz && 7z x example.tar Use && to combine two commands in one