tar command is used to create archive and extract the archive files.
SYNTAX:
The Syntax is
tar [options] [archive-file] [File or directory to be archived]
OPTIONS:
| -c | Creates Archive |
| -x | Extract the archive |
| -f | creates archive with give filename |
| -t | displays or lists files in archived file |
| -u | archives and adds to an existing archive file |
| -v | Displays Verbose Information |
| -A | Concatenates the archive files |
- To archive a directory or file :
tar -cvf backup.tar /etcThis command creates a tarfile called backup.tar which is the archive of /etc directory.
Where, backup.tar - Is a tar file created /etc - Is a directory archived - To archive a directory or file and store it in a storage device:
tar -cvf /dev/fd0 /home/user1/HGBThis command will archive /etc directory and store it in floppy-disk.
Where, /dev/fd0 - Is a floppy-disk name where the archive is stored /home/user1/HGB - Is a directory archived - To Extract the archive:
tar -xvf backup.tarThis command will extract the backup.tar file
- To List The File In An Archive:
tar -tvf backup.tarThe above command will display the files and directories that archived in backup.tar.
No comments:
Post a Comment