541 544




Using Linux:System Maintenance






-->















Previous
Table of Contents
Next




CHAPTER 31System Maintenance

By Tad Bohlsen

Compressing and decompressing files and directories
Compressed archiving with the tar command
Backing up with the taper utility
Using floppy disks and removable drives for backing up
Maintaining a file system
Maximizing disk space
Compressing unused files

Performing System Backups
Making backups is the only way to ensure that you can replace files that become accidentally deleted. To get the most bang for your backup buck (if you can’t back up everything), identify the most important files on your own system. If you use your Linux machine exclusively as a web server, your backup requirements are probably a little different than those of someone who tests software. Try to archive the most critical parts of your system on a regular basis. There is little need to back up applications that you loaded from another storage device (CD-ROM, floppy, and so on) unless you have made major modifications to them. If you are supporting a machine with multiple users, you should definitely set up a backup schedule for the /home directory tree.
Compressing and Decompressing Files and Directories
Often you will need to compress files when backing them up. Compression can also reduce the size of files you are emailing or transferring to someone on diskettes. Linux provides several ways to compress files and directories: The gzip (gnu zip) command is generally considered the best of the bunch for most purposes. gzip’s alter ego, gunzip, decompresses files compressed by gzip. gzip’s basic syntax is as follows:


#gzip filename
gunzip’s syntax is similar:
#gunzip filename


Using gzip and gunzip to compress and decompress files


1.  First, choose a file to compress:


#ls —l frankie.txt
--rw--r----r– 1 tb users 1425 Mar 31 09:22
frankie.txt


2.  Compress the file using the gzip command:


#gzip frankie.txt


3.  Use ls to check the file again (don’t list a filename on the command line). You can see that gzip replaces the file whose filename you provide (frankie.txt in our example) with a compressed version whose name ends in the suffix .gz. The permissions, ownership, and date stamp of the original uncompressed file are retained in the compressed version.


#ls —l
total 1
--rw--r----r– 1 tb users 705 Mar 31 09:22
frankie.txt.gz


4.  Use gunzip to uncompress the compressed file we just made:


#gunzip frankie.txt.gz
#ls -l
total 1
--rw--r----r– 1 tb users 1425 Apr 1 09:22
frankie.txt


gunzip restores the original filename (removing the .gz suffix) and file attributes, removing the compressed file.

gunzip can expand files created with other Linux compression utilities, like the compress command. Table 31.1 contains useful command-line options for the gzip and gunzip commands. You can also use the info command to look at online documentation for gzip:


#info gzip



TABLE 31.1 Commonly used command-line options for gzip and gunzip



Option
Mnenomic
Description



h
help
Lists command line options for gzip and gunzip

v
verbose
When used with gzip, produces a verbose information listing, including the name of the compressed file and the degree of compression (as a percentage of the original file size)

l
list
Lists the original filename(s) of file(s) contained in a compressed file

t
test
Tests to determine the result of a gzip or gunzip command. Indicates expected results without actually executing the specified command

r
recursive
Recursively descends a directory tree, compressing or uncompressing files that match the filename(s) given on the command line

c
concatenate
Accepts input from the standard input, or places output onto the standard output (allows the use of pipes when generating filenames to be compressed or uncompressed)




SEE ALSO• To find out how to use ls to list files and directories, see page 31.

Compressed Archiving with the tar Command

gzip does not allow you to easily compress entire directories or directory trees; to compress directories you must also use the tar (tape archive) command. tar can accept entire filesystems as its input, placing all their directories and files into one file, called a tar file:


#tar -cf tarfile.tar file(s)






Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
544 548
544 (2)
2008 patomorfologia wykl wersja studenckaid&541
539 544
542 544
544,24,artykul
readme (541)

więcej podobnych podstron