Q. How do I extract a single file or directory form a tarball under UNIX / Linux shell prompt? How do I restore a single file from /dev/st0 tape device?
A. tar command allows to extract a single file or directory using the following format. It works under UNIX, Linux, and BSD operating systems.
tar xvf /dev/st0 filename
tar xvf /dev/st0 directory-name
tar xvf mytar.ball.tar filename
tar -zxvf mytar.ball.tar.gz directory-name
Extract file to /tmp directory
tar -zxvf mytar.ball.tar.gz -C /tmp filename
tar -zxvf mytar.ball.tar.gz -C /tmp dir-name
Read tar man page for more information:
man tar
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -


{ 2 comments… read them below or add one }
Hi,
I am running the same command to extract a directory from the tape backup. But its taking lot of time. So I have cancelled it
Could you tell me will it take time or else there is any other command which execute faster.
Thanks
Raju
Raju,
tar will take time, even when extracting a single file it will take a long time to complete if the tarball is big.
I know of nothing faster than tar to extract from a tar. Maybe just background the process and wait.
Cheers