550 554




Using Linux:System Maintenance






-->















Previous
Table of Contents
Next




There are more options available for the find command than for almost any other Linux utility. See Table 31.3 for useful search rules to use with find.
TABLE 31.3 find command search expressions



Expression
Type
Function



-atime/-mtime/-ctime
test
Tests whether file(s) were created before (+n), after (-n) or on (n), where n is an integer representing n number of days before today. (For example, -ctime -5 would find all files changed within the last five days.)

-depth
option
Processes the files in each directory before checking the permissions of the directory itself.

-exec command {} \;
action
Executes command for each file passed to it.

-group groupname
test
Tests whether files are owned by group groupname.

-name filename
test
Tests whether filenames passed to it match filename.

-nouser
test
Tests for files with no user associated; useful for finding “orphaned” files that could be archived or deleted.

-ok command {} \;
action
Like exec, except prompts user before executing command on each file passed to it.

-path pathname
test
Tests whether the path of the file(s) passed to it matches pathname.

-prune
action
Skips directories passed to it (often used with -path, where -path identifies the directory to skip and passes the name to prune).

-regex expression
test
Tests whether the filename(s) passed to it match a regular expression.

-size nk
test
Tests whether files passed to it are n KB in size (can use +n or -n for greater or less than n).

-type d
test
Tests whether files are of type d (directories).

-user username
test
Tests whether files are owned by user username.

-xdev
option
Instructs find to search on the current device only (for example, only on the hard drive).



Locating Files Based on Their Access Times
You’ve seen how find can locate files based on their access times (for example, the most recent time the file was accessed, or used) in Chapter 3, “Navigating the Linux File System.”


#find /dev -atime +30 -print


This command prints to the screen the device files that haven’t been accessed for the past 30 days. You can build a list of files to archive based on their most recent access times. However, it’s sometimes necessary to change files’ access times to make sure the find command locates them during a search.
To update a file’s access times, use the touch command:


#touch $HOME/*


Using the touch command like this changes the access times of all files in your home directory to the current system time.
You can then use the tar command to select files based on access times when archiving.


#ls -l $HOME
total 2
—rwxrwxr—x 1 me users 22843 Apr 1 9:40
README.txt
—rwxrwxr—x 1 me me 1519 Apr 1 9:40
iousage

#tar -cvz -N DATE -f home.tar.gz $HOME


The N option tells tar to archive only those files with access times more recent than DATE, where the date is given in the format of the date command.
For more information about the find and tar commands, consult their respective man pages.

SEE ALSO

•  For more information about regular expressions, see page 25.
•  For more information about file attributes (date stamps, permissions, and ownership) see page 43 and page 418.
•  For more information about the touch command and file date stamps, see page 36.



Using taper for Backups

Red Hat Linux 5.0 includes a backup utility developed by Yusuf Nagree called taper. You can use the Red Hat package manager utility, rpm, to query whether the taper package was installed on your system with Red Hat Linux 5.0.


#rpm -q taper
taper-6.8.0a10-1


If you do not have the taper package installed, you can use the rpm or glint utility to install it.
You can run the taper utility entirely from the command line, but it is made to use a menuing system. The main piece of information you must supply is the type of backup device you use.


#taper -T device type indicator


Table 31.4 lists the device types you can use with taper, and the device type indicator for each.
TABLE 31.4 Device type options to use when starting taper



Device Indicator
Mnenomic
Description



z
zftape
Newest floppy drive tape driver, recommended for use if you have the zftape device driver

f
ftape
Older floppy drive tape driver, use if the ftape version you use is earlier than version 3.0

r
removable
Use when backing up to floppies and other removable devices (like Zip drives)

s
scsi
Use with SCSI tape drives







Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
550 554
548 550
2 modulid 550
GE 550 L&S [GV] L293 82 3
547 550
GE 550 DeVlieg 4K M908 89
GE 550 LeBlonde [KSW] L219 82 8
GE 550 M087 87

więcej podobnych podstron