Tar Command With Simple Example
tar command is the primary archiving utility for unix/linux.
Today we will see uses of "tar" with an example of tar a whole directory (old_dir) content to another directory(new_dir)
1.Create an archive
$ ls
old_dir new_dir
$ cd old_dir
$ tar -cvf new_dir/backup.tar . <<--here use period "." not "*" as "*" will not include hidden files/dir (specially if you are using tar for /home dir as lots of hidden files/dir will be there i.e. .ssh,.bashrc etc)
In the above command:
c – create a new archive
v – verbosely list files which are processed.
f – following is the archive file name
2.Extracting (untar) an archive
$ cd new_dir
$ ls
backup.tar
$ tar -xvf backup.tar
x – extract files from archive
Today we will see uses of "tar" with an example of tar a whole directory (old_dir) content to another directory(new_dir)
1.Create an archive
$ ls
old_dir new_dir
$ cd old_dir
$ tar -cvf new_dir/backup.tar . <<--here use period "." not "*" as "*" will not include hidden files/dir (specially if you are using tar for /home dir as lots of hidden files/dir will be there i.e. .ssh,.bashrc etc)
In the above command:
c – create a new archive
v – verbosely list files which are processed.
f – following is the archive file name
2.Extracting (untar) an archive
$ cd new_dir
$ ls
backup.tar
$ tar -xvf backup.tar
x – extract files from archive
Comments
Post a Comment