2. Managing
• Linux uses files for storing most object types on the system,
such as user programs and data
• Linux power tools has three main tool categories for
managing file “trees”
– Archive Tools
While working with a large amount files using an archive can reduce
the complexity in transferring, backing up or restoring entire file
“trees”
– Compression Tools
Used in order to reduce files footprint. Usually used on archives
– Synchronization Tools
Synchronize two directories
3. tar
• “tar” is a tool that can create and extract archives. This is the
most commonly used archiving tool on Unix and Linux
• Syntax:
tar c[options] filename(s)
tar x[options]
• Options:
c create a new archive
x extract an existing archive
t list files inside archive
f file use file as the archive destination (default is STDIN/STDOUT)
v be verbose
z use ZIP compression on archive
j use BZIP compression on archive
4. gzip
• “gzip” is a compression tool which is based on the Lempel/Ziv
algorithm for data compression
• Syntax:
gzip [options] filename(s)
• Options:
-d extract a compressed file in-place (overwrite the original file)
-c send output to the STDOUT instead of overwriting the file
-N set compression level (1-fast 9-small)
Note: The default action of gzip is to compress a file.
gzip can only compress a single file, this usually being used with
an archiving tool
5. gzip
• “gzip” is bounded with some other command line tools which
can help working with compressed files. These are
implementations or other basic tools, while adding the
compression layer on top of them.
zless
zcat
zgrep
zmore
6. rpm
• “rpm” is the most fundamental tool for managing special
software package archives. The name stands for
Redhat Package Management and the archive format is
dedicated to this task.
• Creating rpm archives is usually done by software vendors or
distributors.
• Syntax:
rpm [options] filename(s)
• Options:
-i install a new package
-e erase a package
7. rpm
-v be verbose
-h display progress bar hashes
-qa query all installed packages on the system
-qi package show information on package
-ql package show list of all files included in package
-qf file show the origin package of file
• Examples
rpm -ivh mySoftware.rpm
rpm -e mySoftware
rpm -qi perl
rpm -qf /bin/bash
8. rsync
• “rsync” is a synchronization tool for files and directory
structures in Unix and Linux. It support both local and remote
synchronization. After the initial sync, it will only transfer new
pieces of data
• Syntax:
rsync [options] source destination
• Options:
-a archive. preserve permissions, times stamps, etc
-z use compression when transferring files
-v be verbose
9. rsync
• Example
# ls source/ dest/
dest/:
source/:
file1 file2 file3
# rsync -av source/ dest/
file1
file2
file3
sent 224 bytes received 72 bytes 197.33 bytes/sec
# echo 456 > source/file2
# rsync -av source/ dest/
file2
sent 131 bytes received 31 bytes 324.00 bytes/sec
Hinweis der Redaktion
Exercise: - create a new tar archive with all the files in your home directoryCreate a new folder: restoreMake sure your archive has all the required files
Exrcise: - Which package installed the ls command ? - Which other command files were installed with it (filter out only command files)
Example online: If time permits
Exrcise: - Which package installed the ls command ? - Which other command files were installed with it (filter out only command files)