NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

UNIX LINUX IMPORTANT QUESTION ANSWER PART 4

UNIX LINUX IMPORTANT QUESTION ANSWER 

for IGNOU BCA MCA Students


tar command in UNIX or Linux is one of the important command which provides archiving functionality in unix. we can use UNIX tar command to create compressed or uncompressed archive files by using either gzip or bzip2. In this unix tar command tutorial we will see examples of unix tar command related to basic archiving task 


How to use tar command in Unix



Using tar command in UNIX is simple and it has similar syntax like any other UNIX command. below is the syntax of tar command in UNIX:


tar [options] [name of tar file to be created] [list of files and directories to be included]


This syntax of tar command is for easy understanding you can also check detailed syntax by using command "tar --usage" in unix machine.

tar command examples in Linux




Unix tar command line options

---------------------------------------

In this section of UNIX tar command tutorial we will see some useful options of tar command in Linux and we will use this options on our example to understand usage of this option along-with tar command.


c -- create, for creating tar file

v -- verbose, display name of files including,excluding from tar command

f -- following, used to point name of tar file to be created. it actually tells tar command that name of the file is "next" letter just after options.
  x -- extract, for extracting files from tar file.         t -- for viewing content of tar file  
z -- zip, tells tar command that create tar file using gzip.

j - another compressing option tells tar command to use bzip2 for compression r -- update or add file or directory in already existed .tar file
wildcards -- to specify patters in unix tar command




How to create tar archive or tar file in Unix

-------------------------------------------------------

Most of use use either winzip or winrar in windows machine to zipping or creating archives of content so when we move to command line interface like Unix or Linux we struggle without those tools. UNIX


tar command is similar to winzip or winrar and you can use UNIX tar command to create both compressed or uncompressed (zipped) archives in UNIX.
  In this example of tar command we will create tar file including all the files and directories or selected                        files and directories in Unix.


here is our directory



total 0

-r--r--r--  1 stock_trader Domain Users 0 Jul 15 11:42 equity drwxrwxrwx+ 1 stock_trader Domain Users 0 Jul 15 14:33 stocks/
-r--r--r--  1 stock_trader Domain Users 0 Jul 15 15:30 currency


it has two files and one directory. now we will create a tar file with all these contents.



currency equity stocks/
stocks/online_stock_exchanges.txt


You see unix tar command is creating tar file with name "trading" with contents shown above. just to review here "-c" is used to create tar file "v" is used to be verbose and "f" is used to tell tar file name.
You can see the tar file here



No comments:

Post a Comment