Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Using Tar command in linux to compress and uncompress the files

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 523
    Comment on it

    One of the frequent task that we do with the increasing data on our linux boxes is to compress the files and folders and to do so there is a command tar that we can use to achieve the same.

    Below are the examples of how to compress files in a folder to create a tar file.

    tar -cvf mycompressedfile.tar /home/user/
    

    where mycompressedfile.tar would be the file name for the compressed file you need to create and /home/user would be the path to the folder you want to compress.

    You can use this command to perform tasks based on various filters too, for eg. if you need to create a backup file for all the .gif files in the folder you can simply change the command to.

    tar -cvf mycompressedfile.tar /home/user/*.gif
    

    This would create a file mycopressedfile.tar containing all the files with .gif extensions in the /home/user/ directory.

    To un-compress the file again you can execute command.

    tar -xvf mycompressedfile.tar
    

    The v switch in the above commands refer to verbose which displays the verbose output for the command and can be omitted if not needed.

    Hope this helps. Naren

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: