compress
[ -f ] [ -v ] [ -c ] [ -V ] [ -r ] [ -b bits] [name ]
uncompress
[ -f ] [ -v ] [ -c ] [ -V ] [ name ]
Compress makes files smaller via adaptive Lempel-Ziv encoding, uncompress (and zcat) reverse the effects of compress. Usually the resultant files are replaced with a similarly named file with a .Z extension. Access permissions, ownership, and modification times are retained.
Example: To compress the file bigfile.txt, use
compress bigfile.txt
-c | Send results to standard output without changing the files |
-r | Recursive operation. Compress the contents of any directories found |
-V | Display version information |
-b | bits encoding |
-v | Verbose operation |
cpio
{-o|--create} [-0acvABLV] [-C bytes] [-H format] [-M message] [-O [[user@]host:]archive][-F[[user@]host:]archive] [-file=[[user@]host:]archive] [--format=format] [--sparse] [--message=message] [--null] [--reset-access-time] [--verbose] [--dot] [--append] [--block-size=blocks] [--dereference] [--io-size=bytes] [--help] [--version] < name-list [> archive]
cpio
{-i|--extract} [-bcdfmnrtsuvBSV] [-C bytes] [-E file] [-H format] [-M message] [-R [user] [:.][group]] [-I [[user@]host:]archive] [-F [[user@]host:]archive] [--file=[[user@]host:]archive] [--make-directories] [--nonmatching] [--preserve-modification-time] [--numeric-uid-gid] [--rename] [--list] [--swap-bytes] [--swap] [--dot] [--unconditional] [--verbose] [--block-size=blocks] [--swap-halfwords] [--io-size=bytes] [--pattern-file=file] [--format=format] [--owner=[user] [:.] [group]] [--no- preserve-owner] [--message=message] [--help] [--version] [-no-absolute-filenames] [-only-verify-crc] [-quiet][pattern ] [< archive]
cpio
{-p|--pass-through} [-0adlmuvLV] [-R [user][:.] [group]] [--null] [--reset-access-time] [--make-directories] [--link] [--preserve-modification-time] [--unconditional] [--verbose] [--dot] [--dereference] [--owner=[user][:.] [group]] [--sparse] [--no-preserve-owner] [--help] [--version] destination-directory<name-list
The cpio command works on archives. An archive file may be on the hard drive, floppy drive, or tape. Generally speaking, cpio accepts a list of files to be processed from standard input (unless otherwise specified), processes them, and sends the resultant archive to standard output or some device. There are three modes of operation:
1. Copy-out mode. Copy the list of input files into an archive. Typically, the list of input files are generated via the find command. Once generated, the archive goes to standard output.
2. Copy-in mode. Copy files out of an archive or list the archive contents. The archive is read from standard input. If shell pattern matching characters are included in the command line, only those files which match the specified pattern will be disinterred; otherwise, all files are extracted.
3. Copy-pass mode. Copy files from one directory tree to another. The list of files to be copied is read from standard input, and the target directory is passed as an argument.
Example: To archive the current directory, list out all the files in it, pipe them to cpio, and redirect the output to the file directory.cpio. Here's the code to use:
ls | cpio -ov > directory.cpio
Example: To extract (-i option) the archive created in the previous example, redirect the contents of the archive to the program by using this command:
cpio -iv < directory.cpio
-0, --null | Specify that the input list will be terminated by a null character, rather than a newline. |
-a, --reset-access-time | Reset the access times of files after reading them so that it looks as if they haven't been read. |
-A, --append | In copy-out mode, append to an existing archive. |
-b, --swap | Swap halfwords of words and bytes of halfwords in the data. Used in converting between big-endian and little-endian machines. |
-B | Specify a block size of 5120 bytes, rather than the 512 byte default. |
--block-size=BLOCKSIZE | Specify a block-size value of BLOCKSIZE * 512 bytes. |
-c | Tell cpio to use the portable (ASCII) archive format. |
-CIOSIZE, --io-size=IOSIZE | Specify an I/O block size of IOSIZE bytes. |
-d, --make-directories | Enable directory creation as appropriate. |
-EFILE, --pattern-file=FILE | Tell cpio to read patterns specifying filenames for listing or extracting from FILE. |
-f, --nonmatching | Tell cpio to copy only files that do not match any of the specified patterns. |
-F, --file=archive | Tell cpio to send output to the specified archive file, rather than standard input or output. |
--force-local | Specify that the archive name given is a local file, even if it contains a colon. |
-H FORMAT, --format=FORMAT | Specifies use of one of the following formats: |
| bin Obsolete binary format. |
| odc Old (POSIX.1) portable format. |
| newc New (SVR4) portable format, which supports file systems having more than 65536 i-nodes. |
| crc New (SVR4) portable format with a checksum added. |
| tar Old tar format. |
| ustar POSIX.1 tar format. Also recognizes GNU tar archives. |
| hpbin Obsolete HPUX binary format. |
| hpodc Portable format used by HPUXs cpio. |
-i, --extract | Specify copy-in mode. |
-Iarchive | Specify an archive filename to be used rather than standard input. |
-k | No effect. Included for backward compatibility. |
-l, --link | Tell cpio to link files, rather than to copy them whenever possible. |
-L, --dereference | Tell cpio to copy the file to which a symbolic link points, rather than the link itself. |
-m, --preserve-modification-time | Tell cpio to retain the archived modification times when creating files. |
-MMESSAGE, --message=MESSAGE | Display the specified message when you fill up a backup medium. Basically a prompt to switch tapes. Instances of the string %d will be replaced in the printed message by the volume number. |
-n, --numeric-uid-gid | Display numeric UID and GID information, rather than the user, and group-ids when displaying verbose information. |
--no-absolute-filenames | When this option is used, all files will be created relative to the current directory even if the archive specifies an absolute file name. |
--no-preserve-owner | Tell cpio to set the ownership on any extracted files to the UID of whoever is doing the extracting. |
-o, --create | Specify copy-out mode. |
-Oarchive | Specify an archive file to be used rather than standard output. |
--only-verify-crc | Tell cpio to verify the cyclic redundancy check value of archived files without extracting anything. |
-p, --pass-through | Specify copy-pass mode. |
--quiet | Suppress printing of the block count. |
-r, --rename | Allow interactive renaming of files. |
-R [user][:.][group], --owner[user][:.][group] | Tell cpio to set the ownership of all files created to the specified user. |
-s, --swap-bytes | Swap the bytes of each halfword (2 bytes) in the files. |
-S, --swap-halfwords | Swap the halfwords of each word (4 bytes) in the files. |
--sparse | Tell cpio to write files containing large blocks of zeroes as sparse files. |
-t, --list | Display a table of contents of the input. |
-u, --unconditional | Tell cpio to replace all files, specifically without prompting the user before replacing newer files with older files. |
-v, --verbose | Display a list of files processed. If used with -t, an ls -l style table of contents listing is generated. |
-V --dot | Tell cpio to display a dot (.) for each file processed. |
--version | Display version information and exit. |
dump
[0123456789BbhfusTdWn [argument ]] filesystem
dump
[0123456789BbhfusTdWn [argument ]] directory
The dump command is used to back up filesystems. In the case where the size of the output is larger than the capacity of the storage medium, the output is broken into multiple volumes.
Example: To do a full backup of the /home filesystem, use
dump /home
0-9 | Specify a dump level. Dump level 0 is a full backup of all files regardless of modification time. Dump levels greater than zero tell dump to back up all files that have been modified since the last dump of a lower level (including new files). |
Brecords | Specify the number of dump records per volume (interpreted as the size in kilobytes). |
bblocksize | Specify the number of kilobytes per dump record. |
hlevel | Honor the user "nodump" flag only for dumps at or above the given level. |
ffile | Specify the file to which output is sent. The file may be a special device file (e.g., /dev/rmt12, /dev/rsd1c), an ordinary file or standard output (specified as "-"). |
ddensity | Specify tape density. |
n | Whenever dump requires operator attention, notify all operators in the group "operator" with a wall. |
sfeet | Attempt to calculate the amount of tape needed at a particular density. |
When using the s option, try to err on the side of caution. Better to waste a few feet of tape space than render your entire dump useless. |
u | Tell dump to update the file /etc/dumpdates after a successful dump. |
Tdate | Use the specified date as the starting time for the dump, instead of the time determined from looking in /etc/dumpdates. |
W | After consulting the files /etc/dumpdates and /etc/fstab, dump tells the operator what file systems need to be dumped. |
w | Like W, but prints only those filesystems that need to be dumped. |
gzexe
[ name ]
This nifty little program allows you to compress executable files in place and have them automatically uncompress and execute when you run them. This does, of course, slow down the execution.
-d | Decompress the specified file rather than compressing them. |
To compress a large, rarely used executable file, use |
gzexe big_ol_program
gzip
[ -acdfhlLnNrtvV19 ] [-S suffix] [ name ]
gunzip
[ -acfhlLnNrtvV ] [-S suffix] [ name ]
Gzip is a utility for compressing and storing files by means of Lempel-Ziv coding. Typically, the compressed file is replaced by a similarly named file with the extension ".gz". By default, access modes and modification time are preserved. Also by default, the original source file is removed.
Example: To compress the file bigfile.c into a smaller file called bigfile.gz, use
gzip bigfile.c
Example: To uncompress the file created in the previous example, use the following command:
gunzip bigfile.gz
--stdout, --to-stdout, -c | These options send any output to standard out, but do not change the original files. |
--decompress, --uncompress, -d | Reverse the compression process. |
--force, -f | Force gzip to perform the specified action without prompting, if possible. |
--help, -h | Display a help message, then exit. |
--list, -l | Display the following information for each compressed file: size of compressed file size of uncompressed file ratio of compressed to uncompressed file name of the uncompressed file When used with the --verbose option, the following is also displayed: compression method (deflate, compress, lzh, pack) the 32 bit cyclic redundancy check of the uncom pressed file the time stamp of the uncompressed file When used with the --quiet option, the title and totals line are not displayed. |
--license, -L | Display license information and exit. |
--no-name, -n | Tell gzip not to save (when compressing) or restore (when uncompressing) the original file name and time stamp. |
--name, -N | Tell gzip to both save (when compressing) or restore (when uncompressing) the original file name and time stamp. |
--quiet, -q | Tell gzip not to display any warnings. |
--recursive, -r | Tell gzip to recursively traverse the directory tree, compressing any files it finds. |
--suffix SUF, -S SUF | Tell gzip to substitute the specified suffix for ".gz". |
--test, -t | Tell gzip to test the integrity of a compressed file. |
--verbose, -v | Verbose output. Include name and percentage reduction for each file compressed. |
--version, -V | Display version number and compilation options. |
--fast, --best, -N | Allow the user to make trade-offs between efficiency of compression (--best, or a numeric value of -1) and speed of the compression process (--fast, -9). The default is -6. |
restore key
[name ]
Restore the filesystems saved with dump.
Example: To restore the home filesystem saved with dump in the aforementioned example, use
restore /home
r | Restore (rebuild a filesystem). |
C | Read the backup and compare its contents with files present on the disk. |
R | Restore requests a particular tape of a multivolume set on which to restart a full restore. (See the r key previously mentioned.) |
x | Read the specified files from the given media. |
t | List the names of the specified files if they occur on the backup. |
i | Interactive restoration. When restoring interactively, restore provides a shell-like interface for use in selecting files to be restored. The following commands apply: |
add [arg] | Add current directory or file to the list of files to be extracted. |
cd arg | Change the current working directory as specified. |
delete [arg] | Delete the current file or directory from the list of files to be extracted. |
extract | Extract all listed files from the dump. |
help | Display help information. |
ls [arg] | List the current or specified directory. |
pwd | Print working directory. |
quit | Exit immediately. |
setmodes | All the directories that have been added to the extraction list have their owners, modes, and times set; nothing is extracted from the dump. |
verbose | When set, causes ls command to list the inode numbers of all entries. |
b blocksize | Specify blocksize in kilobytes. |
D filesystem | Specify name of filesystem used by -C option in a comparison. |
f archive | Specify archive to be used, rather than /dev/rmt. |
h | Extract actual directory rather than referenced files. |
m | Extract by inode numbers, rather than by file name. |
N | Do not extract files, only print file names. |
s filenumber | Specify the number of the file on a multifile tape dump. Numbering starts at 1. |
T tmpfiledir | Specify a directory to use for temp file storage. |
v | Verbose operation. List files as they are restored. |
y | Always continue on error, regardless of bad blocks. |
shar
[ OPTION ] FILE
shar -S
[ OPTION ]
This command creates shell archives. They are in text format and thus mailable. To use a shell archive, execute it with /bin/sh. You may specify the files to be archived either on the command line or in a file.
Example: To create an archive of all the text files in the current directory and redirect/save it to the file text.shar, use
shar *.txt > text.shar
--help | Display help information and exit. |
--version | Display version number and exit. |
-q, --quiet | Run with fewer than normal messages. |
-p, --intermix-type | Allow options on the command line to be entered via standard input on a line other than the standard input (-M, -B, -T, -z and -Z only). |
-S, --stdin-file-list | Get file list interactively rather than from the command line. |
-oPREFIX, --output-prefix=PREFIX | Save the archive to files PREFIX.01 through PREFIX.NNN, instead of standard output. |
-lKB, --whole-size-limit=KB | Limit the size of output file to the specified number of kilobytes, but do not split input files. |
-LSIZE, --split-size-limit=SIZE | Limit the size of output file to the specified number of kilobytes, splitting files as necessary. |
-nNAME, --archive-name=NAME | Specify the archive name that will be included in the header of the shar file. |
-sADDRESS, --submitter=ADDRESS | Override the default email address for the submitter. |
-a, --net-headers | Tell shar to automatically generate headers. |
-c, --cut-mark | Start the shar with a cut line. |
-T, --text-files | Treat all files as text. |
-B, --uuencode | Treat all files as binary and use uuencode prior to packing. |
-M, --mixed-uuencode | Tell shar to automatically determine if the files are text or binary and treat them accordingly. |
-z, --gzip | Tell shar to use gzip and uuencode on all files prior to packing. |
-gLEVEL, --level-for-gzip=LEVEL | Use the specified level as a parameter to gzip when doing compression. |
-Z, --compress | Tell shar to use compress and uuencode prior to packing. |
-bBITS, --bits-per-code=BITS | Use -bX as a parameter to compress. |
-w, --no-character-count | Turn off wc -c checking. |
-D, --no-md5-digest | Turn off md5sum checking. |
-F, --force-prefix | Force shar to prepend the prefix character to every line even if not required. |
-dSTRING, --here-delimiter=STRING | Delimit the files in the shar with the specified string rather than SHAREOF. |
-V, --vanilla-operation | Produce a more widely usable shar. |
-P, --no-piping | Specify a temporary file to be used instead of pipes. |
-x, --no-check-existing | Tell shar to overwrite existing files without checking. |
-X, --query-user | Do not overwrite files without first prompting the user. |
-m, --no-timestamp | Do not "touch" the unpacked archive files (preserves original timestamp). |
-Q, --quiet-unshar | Do not spray the user with comments when unpacking. |
-f, --basename | Use only the filename (not the directory path) when building a shar. |
tar
[ - ] A -catenate -concatenate | c -create | d --diff --compare || r --append || t --list || u --update || x -extract --get [ --atime-preserve ] [ -b, --block-size N ] [ -B, --read-full-blocks ] [ -C, --directory DIR ] [ --checkpoint ] [ -f, --file [[HOSTNAMEE:]]F ] [ --force- local ] [ -F, --info-script F --new-volume-script F ] [ -G, --incremental ] [ -g, --listed-incremental F ] [ -h, --dereference ] [ -i, --ignore-zeros ] [ --ignore-failed- read ][ -k, --keep-old-files ] [ -K, --starting-file F ] [ -l, --one-file-system ] [ -LL, --tape-length N ] [ -m, --modification-time ] [ -MM, --multi-volume ] [ -N, --after-date DATE, --newer DATE ] [ -o, --old-archive, --portability ] [ -O, --to-stdout ] [ -p, --same-permissions, --preserve-permissions ] [ -PP, --absolute-paths ] [ --preserve ] [ -R, --record-number ] [ --remove-files ] [ -s, --same-order, --preserve-order ] [ --same-owner ] [ -S, --sparse ] [ -T, --files-from FF ] [ --null ] [ --totals ] [ -v, --verbose ] [ -VV, --label NAME ] [ --version ] [ -w, --interactive, --confirmation ] [ -WW, --verify ] [ --exclude FILE ] [ -XX, --exclude-from FILE ] [ -ZZ, --compress, --uncompress ] [ -z, --gzip, --ungzip ] [ --use-compress-program PROG ] [ --block- compress ] [ -[[0-7]][[lmh]] ] filename1 [ filename2, filenameN ] directory1 [ directory2, directoryN ]
Tar is the tape archive utility, though you don't necessarily need to use it with tapes. Its purpose in life is to pack a bunch of files all together into one file in such a way that they can later be unpacked and separated to their original state. Most Linux distributions rely on tar in one form or another.
By default, tar does not compress the files it is archiving. This means that your resultant archive file takes up more or less the same amount of disk space as the files that went into it. Generally, you'll want to use one of the compression options (--gzip, --compress) when archiving. |
Example: To create (-c option) a tar archive of all the files under your home directory and store them in the archive file mystuff.tar (-f option tells tar that the next argument will be the destination file, in this case, "mystuff.tar"), use
tar -cvf mystuff.tar /home/myhomedir
The -v option tells tar to list the files as it's saving them, just so you have something to watch.
Example: To extract (-x option) all the files from the archive created in the previous example, use
tar -xvf mystuff.tar
Example: To create a tar archive just like the one in the first example, but one that would be compressed (-gzip option) at the same time, use
tar -gzip -cvf mystuff.tar /home/myhomedir
To uncompress and unzip the file "mystuff.tar", created above, use
tar -gunzip -xvf mystuff.tar
Tar requires that you specify at least one of the following options:
-A, --catenate, --concatenate | Append files to an archive. |
-c, --create | Create a new archive. |
-d, --diff, --compare | Display the differences between an archive and the unarchived files, if any. |
--delete | Remove from the archive. |
-r, --append | Append files at the end of an archive. |
-t, --list | Display the contents of the specified archive. |
-u, --update | Tell tar to append only files that are newer than copy in the archive. |
-x, --extract, --get | Extract files from the specified archive. |
Other Options
--atime-preserve | Retain access time on dumped files. |
-b, --block-size N | Specify a block size of Nx512 bytes. |
-B, --read-full-blocks | Reblock as read on 4.2 BSD pipes. |
-C, --directory DIR | Change to the specified directory. |
--checkpoint | Display directory names while reading the archive. |
-f, --file [[HOSTNAME:]FILE] | Use the specified archive file or device. |
--force-local | Force tar to consider the archive file to be local even if the filename contains a colon. |
-F, --info-script F --new-volume-script F | Tell tar to run the specified script at the end of each tape. |
-G, --incremental | Tell tar to create, list, or extract old GNU-format incremental backup. |
-g, --listed-incremental FF | Tell tar to create, list, or extract new GNU-format incremental backup. |
-h, --dereference | Tell tar to archive files that symbolic links point to, rather than the links themselves. |
-i, --ignore-all | Tell tar to ignore blocks of zeros in archive. |
--ignore-failed-read | Tell tar not to exit with nonzero status when files are unreadable. |
-k, --keep-old-files | Do not overwrite existing files in the archive. |
-K, --starting-file F | Begin at the specified file in the archive. |
-l, --one-file-system | Remain in local file system when creating an archive. |
-L, --tape-length N | Will generate a prompt to change tapes after the specified number of kilobytes. |
-m, --modification-time | Suppress extraction of file modification time. |
-M, --multi-volume | Creation, listing, or extraction of multivolume archive. |
-N, --after-date DATE, --newer DATE | Tell tar to store only files newer than DATE. |
-o, --old-archive, --portability | Store archive in V7 format, rather than ANSI format. |
-O, --to-stdout | Send output to standard out. |
-p, --same-permissions, --preserve-permissions | Retain all security information. |
-P, --absolute-paths | Suppress stripping of leading "/"s from file names. |
--preserve | Same as -p -s. |
-R, --record-number | Include record number within archive with messages. |
--remove-files | Delete daily files from filesystem after adding them to the archive. |
-s, --same-order, --preserve-order | Tell tar to sort list of target names to match archive. |
--same-owner | Retain ownership when extracting files. |
-S, --sparse | Tweak performance to handle sparse files better. |
-T, --files-from F | Specify that file F will contain name list. |
--null | When used with -T, specifies that filenames will be null terminated. |
--totals | Display total bytes written when creating archive. |
-v, --verbose | Verbose output (list files). |
-V, --labelNAME | Create archive with the specified volume name. |
--version | Output version information. |
-w, --interactive, --confirmation | Prompt for confirmation before taking action. |
-W, --verify | Verify archive after writing. |
--excludeFILE | Exclude the specified file from processing. |
-X, --exclude-fromFILE | Exclude from processing all files specified in file. |
-Z, --compress, --uncompress | Compress or uncompress the archive with compress. |
-z, --gzip, --ungzip | Compress or uncompress the archive with gzip. |
--use-compress-programPROG | Filter the archive through the specified program. (PROG must accept the -d option.) |
--block-compress | Block the output of any compression program for tapes. |
-[0-7][lmh] | Allows the user to specify drive and density. |
unshar
[ OPTION ] [ FILE ]
Unpack a shar file. Shar files are "shell archive" files, created with the shar command. (See shar command for details.)
Example: To unpack the shar file text.shar, use
unshar text.shar
--version | Display version information and exit. |
--help | Display help information and exit. |
-d DIRECTORY, --directory=DIRECTORY | Relocate to the specified DIRECTORY before unpacking files. |
-c, --overwrite, -f, --force | Tell shar to overwrite existing files. |
-e, --exit-0 | In the case where unpacking from a single mail folder containing many shar archives, split them up when unpacking. (Assumes the various shars are delimited by an exit 0.) |
-E STRING, --split-at=STRING | Similar to -e, but allows you to specify the delimiter string. |
uuencode
[-m] [ file ] name
uudecode
[-o outfile] [ file ]
The uuencode/uudecode programs are used to encode binary files for transmission over media that support only transmission of ASCII data.
Example: To encode the binary file program and mail to user someguy@wherever.com, use
uuencode program | mail someguy@wherever.com
-m | Use base64 encoding format. |
-o | Write output to the specified file. |
zcmp
[ cmpoptions ] file1 [ file2 ]
zdiff
[ diffoptions ] file1 [ file2 ]
Compare files that are currently compressed. The options for these commands are exactly the same as the options for cmp and diff, respectively.
Example: To compare the contents of the compressed file a.gz with the compressed file b.gz, use
zcmp a.gz b.gz
zgrep
[ grepoptions ] [ -e ] pattern filename
This command is used to grep through compressed or zipped files.
The options for this command are the same as for grep.
Example: To look for the string "important clue" in all the compressed files in your current directory (assuming they have a .gz file extension), use
zgrep "important clue" *.gz
zmore
[ name ]
View compressed files. The zmore command is interactive, hence, the following keys apply:
Example: To display the contents of the zipped file a.txt.gz, use
zmore a.txt.gz
#<space> | Display # more lines, or another screenful if no # specified. |
^D,d | Scroll forward. |
#z | Same as a space, but may be used to specify a new window size. |
#s | Skip # lines and print a screenful starting at that point. |
#f | Skip # screenfuls and print a screenful starting at that point. |
q, Q | Quit reading the current file and go on to the next one. |
e | Exit. |
s | Skip the next file and continue. |
= | Display the current line number. |
#/expr | Search for the #th occurrence of the specified regular expression. |
#n | Where # is some number, search for the #th occurrence of the last regular expression entered. |
!command | Run the specified shell command. |
:q or :Q | Stop displaying the current file. |
. | Repeat the previous command. |
znew
[ -ftv9PK] [ name.Z ]
Recompress the specified files from compress (.Z) format to gzip (.gz) format.
Example: To convert the file program.Z from compress format to gzip format, use
znew program.Z
-f | Force recompression even if the .gz file already exists. |
-t | Test any new zip files before deleting originals. |
-v | Run in verbose output. |
-9 | Optimal compression, slowest execution. |
-P | Reduce disk space usage by using pipes in the conversion. |
-K | If the .Z file is smaller than the .gz file, keep it. |