Let’s add /etc/fstab file in ‘ data.tar‘ ~]# tar -rvf data.tar /etc/fstab ‘ -r‘ option in the tar command is used to append or add file to existing tar file. ~]# Example 3) Append or add files to end of archive rw- root/root 953 01:33 root/anaconda-ks.cfg ~]# tar -tvf myarchive.tar root/anaconda-ks.cfg In the below example i am trying to view whether ‘anaconda-ks.cfg’ file is there in the tar file or not. Listing a specific file or directory from tar file. Using ‘ –t‘ option in tar command we can view the content of tar files without extracting it. ~]# Example 2) List the content of archive file In the tar command ‘ -c‘ option specify to create a tar file, ‘ -v’ is used for verbose output and ‘ -f’ option is used to specify the archive file name. Tar file contains all the files and directories of /etc folder and anaconda-ks.cfg file. ~]# tar -cvf myarchive.tar /etc /root/anaconda-ks.cfgĪbove command will create a tar file with the name “ myarchive” in the current folder. Let’s create a tar file of /etc directory and ‘/root/ anaconda-ks.cfg’ file. Note : hyphen ( – ) in the tar command options are optional. Some of the commonly used options in tar command are listed below :
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |