Книга: Fedora™ Unleashed, 2008 edition

Copying Files Using cp

Copying Files Using cp

To copy files, we could use the cp command. The general format of the command when used for simple copying is the following:

$ cp -a source_directory target_directory

The -a argument is the same as giving -dpR, which would be

-d — Dereferences symbolic links (never follows symbolic links) and copies the files to which they point, instead of copying the links.

-p — Preserves all file attributes if possible. (File ownership might interfere.)

-R — Copies directories recursively.

You can also use the cp command to quickly replicate directories and retain permissions by using the -avR command-line options. Using these options preserves file and directory permissions, gives verbose output, and recursively copies and re-creates subdirectories. You can also create a log of the backup during the backup by redirecting the standard output like this:

# cp -avR directory_to_backup destination_vol_or_dir 1>/root/backup_log.txt

or

# cp -avR fedora /test2 1>/root/backup_log.txt

This example makes an exact copy of the directory named /fedora on the volume named /test2, and saves a backup report named backup_log.txt under /root.

Оглавление книги


Генерация: 0.674. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз