redhat で tar 形式のファイルを展開する方法は次の通り。
○ tar ファイルを展開する
> tar xvf [展開したい tar ファイル]
ただ、tar ファイルは展開しなくても中身を確認することができる。
なので、展開する前に中身を確認するようにしておいた方が良い。
○ tar ファイルを展開せずに中身を確認する
> tar tvf [確認したい tar ファイル]
○確認・展開の実行例
対象を test.tar として、まずは確認。
# tar tvf test.tar -rw-r--r-- root/root 22 2006-12-10 18:51:51 test-file1 -rw-r--r-- root/root 53 2006-12-10 18:51:53 test-file2 -rw-r--r-- root/root 117 2006-12-10 18:51:54 test-file3 drwxr-xr-x root/root 0 2006-12-10 18:52:54 test-dir/ -rw-r--r-- root/root 231 2006-12-10 18:51:55 test-dir/test-file4 -rw-r--r-- root/root 372 2006-12-10 18:51:56 test-dir/test-file5
出力をみて tar ファイルを展開するとどこに何ができるかを確認すると、
カレントディレクトリに test-file1, test-file2, test-file3, test-dir ができて、
test-dir の中にtest-file4, test-file5 ができる、ことが分かる。
続いて、tar ファイルを展開する。
# tar xvf test.tar test-file1 test-file2 test-file3 test-dir/ test-dir/test-file4 test-dir/test-file5
ディレクトリの構成や権限などの属性が変更されずに、
展開されていることが分かる。
# ls -al drwxr-xr-x 2 root root 10240 12月 10 2006 test-dir -rw-r--r-- 1 root root 22 12月 10 2006 test-file1 -rw-r--r-- 1 root root 53 12月 10 2006 test-file2 -rw-r--r-- 1 root root 117 12月 10 2006 test-file3
# ls -al test-dir drwxr-xr-x 2 root root 4096 12月 10 2006 . drwxr-xr-x 2 root root 4096 1月 12 20:03 .. -rw-r--r-- 1 root root 231 12月 10 2006 test-file4 -rw-r--r-- 1 root root 372 12月 10 2006 test-file5
redhat で tar コマンドを使う