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
Showing posts with label UNIX Linux. Show all posts
Showing posts with label UNIX Linux. Show all posts

UNIX LINUX IMPORTANT QUESTION ANSWER PART 5

UNIX LINUX IMPORTANT QUESTION ANSWER 

for IGNOU BCA MCA Students




-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


-rw-r--r--  1 stock_trader Domain Users 10K Jul 18 12:29 trading.tar




How to view contents of tar file in Unix or Linux

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



In earlier example of tar command in Unix or Linux we have created a uncompressed tar file called

"trading.tar" now in this example we will see the actual content of that tar file.



-r--r--r-- stock_trader/Domain Users 0 2011-07-15 15:30 currency

-r--r--r-- stock_trader/Domain Users 0 2011-07-15 11:42 equity drwxrwxrwx stock_trader/Domain Users 0 2011-07-15 14:33 stocks/
-rwxrwxrwx stock_trader/Domain Users 0 2011-07-15 14:33

stocks/online_stock_exchanges.txt


here option "t" is used to display content of tar file in unix while options "v" and "f" are for "verbose" and "following". now you can clearly see that all the files which we wanted to be included in tar file are there.




How to extract contents from a tar file in Unix

-----------------------------------------------------------
In this example of unix tar command we will see how to extract files or directories from a tar file in unix or Linux. We will use same trading.tar file created in earlier example. In this example we will create a directory "trading" and extract contents of trading.tar on that directory.



total 12K

-rw-r--r-- 1 stock_trader Domain Users 10K Jul 18 12:37 trading.tar


Now the directory is empty just trading.tar file



currency equity stocks/
stocks/online_stock_exchanges.txt


This unix tar command will extract content of trading.tar in current directory. "x" is used for extracting. "v" is again for verbose and optional parameter in all our example.



-r--r--r--  1 stock_trader Domain Users   0 Jul 15 11:42 equity drwxr-xr-x+ 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


-rw-r--r--  1 stock_trader Domain Users 10K Jul 18 12:37 trading.tar


Now you can see that all the files and directories which were included in tar file (stocks, equity and currency) has been extracted successfully.




How to create tar file in Unix with just specified contents

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

In above example of tar command in unix we have created tar file with all the contents available in current directory but we can also create tar file with selective content as shown in above example.

Now in our current directory we have both files and directories and we just want to include two files equity and currency in our tar file.




-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

-rw-r--r--  1 stock_trader Domain Users 10K Jul 18 12:29 trading.tar drwxr-xr-x+ 1 stock_trader Domain Users   0 Jul 18 12:46 new/



equity currency


you see only two files equity and currency are included in our tar file.




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