File Compression in Linux

Compress an Entire Directory or a Single File

Use the following command to compress an entire directory or a single file on Linux. It’ll also compress every other directory inside a directory you specify–in other words, it works recursively.

tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

Here’s what those switches actually mean:

  • -c: Create an archive.
  • -z: Compress the archive with gzip.
  • -v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
  • -f: Allows you to specify the filename of the archive.

Let’s say you have a directory named “stuff” in the current directory and you want to save it to a file named archive.tar.gz. You’d run the following command:

tar -czvf archive.tar.gz stuff

Or, let’s say there’s a directory at /usr/local/something on the current system and you want to compress it to a file named archive.tar.gz. You’d run the following command:

tar -czvf archive.tar.gz /usr/local/something

时间: 2024-07-31 14:34:55

File Compression in Linux的相关文章

File Compression and Archiving in linux (linux 中文件的归档)

1. Compressing Files at the Shell Prompt Red Hat Enterprise Linux provides the bzip2, gzip, and zip tools for compression from a shell prompt. The bzip2 compression tool is recommended because it provides the most compression and is found on most UNI

C语言下的FILE指针与Linux的文件描述符

FILE*:它是C库中定义的一个结构体指针,我们在C语言文件操作时打开一个文件返回的指针类型就是它,在C库中是这样定义的,其中的_file它是一个整数,就是作为文件索引的描述符,C库是建立在系统调用上的,这个FILE结构体可以说是一个包装,底层还是用文件描述符对磁盘上的文件进行连接的. 文件描述符:在linux系统中每打开一个文件就会获取一个文件描述符,他是一个小整数,在linux下0号1号2号文件操作符分别是标准输入,标准输出,标准错误. 每个进程在运行时都会有个PCB,而PCB中都会有一张文

EnCase v7 could not recognize Chinese character folder names / file names on Linux Platform

Last week my friend brought me an evidence file duplicated from a Linux server, which distribution is CentOS 5.0 and the i18n is zh-tw. She wanna know whether there is any malware on this Linux server or not. OK. Let's get to work. I add this evidenc

File System in Linux

Linux File Systems 0. Introduction     ext4是Linux流行的File System,     mkfs是格式化Disk总的命令,用于在特定的分区上建立 linux 文件系统.    使用方式 : mkfs [-V] [-t fstype] [fs-options] filesys [blocks]    参数 : device : 预备检查的硬盘分区,例如:/dev/sda1 -V : 详细显示模式 -t : 给定档案系统的型式,Linux 的预设值为

file命令及Linux重要关键路径介绍

file:决定文件类型 文件系统:rootfs:根文件系统 /boot:系统启动相关的文件,如内核,initrd,以及grub(bootloader引导加载器)/Dev:设备文件    设备文件:        块设备:随机访问,数据块        字符设备:现行访问(有次序的),按字符为单位        设备号:主设备号(major)和次设备号(minor)/etc:配置文件/home:用户的家目录,每一个用户的家目录通常.默认为/home/USERNAME /root:管理员的家目录:/

Linux启动网卡时出现RTNETLINK answers: File exists错误解决方法

这里说一下,如果复制了虚拟机,设置新的MAC地址为什么? 在虚拟机的网络设置中--->高级.然后找到如下窗口,生成新的MAC地址即可. -------------------------------------------------------------------------------- 一.问题描述VMware中克隆虚拟机是经常的事情,虽然如此,用到虚拟机时,本人还是喜欢新安装一个操作系统,针对服务器的应用,在安装操作系统时,一并安装好,并且也花不了多少时间.但最近需要大量的配置一样的

Linux 操作系统下 File.Delete 的表现

在我的上一篇随笔"对 File.Delete 方法的一点看法"中,在 Windows 操作系统上对 File.Delete 方法进行了测试.这次,在 Linux 操作系统上使用 mono 的最新版本 1.2.5 版对 File.Delete 方法进行测试. 下面是我的运行 Linux 操作系统的计算机的基本信息: [email protected]:~/work$ cat /etc/issue.net Ubuntu 6.10 [email protected]:~/work$ unam

Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

How do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux? The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that a

Linux Kernel File IO Syscall Kernel-Source-Code Analysis(undone)

目录 0. 引言 1. open() syscall 2. close() syscall 0. 引言 在linux的哲学中,所有的磁盘文件.目录.外设设备.驱动设备全部被抽象为了"文件"这个概念,所以本文提到的"File IO"适用于linux下所有的IO操作,需要明白的的,本文分析的是linux下的IO系统调用对应的内核源代码,linux下每一个系统调用都有对应的内核源代码,而我们在ring3常用的glib c的编程所有的c库API,它们只是对系统调用的一个封装