Chapter 13
ARCHIVING AND TRANSFERRING FILES
ARCHIVING AND TRANSFERRING FILES
By default tar command is not storing extended attributes (SELinux permissions), to store them, you must use --xattr
option.
# to archive files with extended attributes use --xattr option:
tar --xattr -cvf archive.tar file1 file2 file3
# -c for : archive.tar
# -z or --gzip : archive.tar.gz or archive.tgz
# -j or --bzip2 : archive.tar.bz2
# -J or -xz : archive.tar.xz
# to list files in archive file use -t option:
tar -tf archive.tar
# to extract tar file use -x option:
tar -xvf archive.tar
TRANSFERRING FILES BETWEEN SYSTEMS SECURELY
remote system to local system:
scp -r username@remotehost:/remote/directory/path localFolder
local system to remote system:
scp -r localFolder username@remotehost:/remote/directory/path
TRANSFERRING FILES USING THE SECURE FILE TRANSFER PROGRAM
sftp remoteuser@remotehost
mkdir remoteFolder
cd remoteFolder
put /etc/hosts # upload hosts file to remote
get /etc/yum.conf # download yum.conf from remote
exit
SYNCHRONIZING FILES BETWEEN SYSTEMS SECURELY
rsync -av root@serverb:/var/log ~/serverlogs
# it can also be used for syncronizing local directories:
rsync -av /var/log /tmp
-v, --verbose
-A
to preserve ACLs
-X
to preserve SELinux contexts
-a, --archive
APPLIES ALL OPTIONS DOWN BELOW:
-r, --recursive
synchronize recursively the whole directory tree
-l, --links
synchronize symbolic links
-p, --perms
preserve permissions
-t, --times
preserve time stamps
-g, --group
preserve group ownership
-o, --owner
preserve the owner of the files
Last updated
Was this helpful?