As you probably know tar is designed to store and extract files from an archive file (a tarfile). Here I’ll show you some basic usage of this tool…
Here we go!
Archive a set of files:
tar -cvf tarfile.tar /var/log/syslog /var/log/messages
Archive and compress (gzip) a set of files:
tar -cvzf file.tar.gz /var/log/syslog /var/log/messages
Archive and compress (bzip2) a set of files:
tar -cvjf file.tar.bz2 /var/log/syslog /var/log/messages
Extract a tar file:
tar -xvf file.tar
tar -xvzf file.tar.gz
tar -xvjf file.tar.bz2
Display the content of a tar file:
tar -tvf file.tar
tar -tvzf file.tar.gz
tar -tvjf file.tar.bz2
Replace a file in an existing tar file:
tar -rvf tarfile.tar filetoreplace
Update a file in an existing tar file:
tar -uvf tarfile.tar newfile
Copy all files in one directory to another directory on local host:
cd /etc; tar cf – . | (cd /etc.bak; tar xvpf -)
Copy a directory from one host to another and preserve ownership and permissions:
tar -cf – /var/amavisd | ssh user@otherhost tar -xf -
Categories
Accounting
                                    
                                            1
                                        
                                                                    Advanced
                                    
                                            4
                                        
                                                                    Client Area
                                    
                                            11
                                        
                                                                    Cloudflare
                                    
                                            11
                                        
                                                                    cPanel
                                    
                                            6
                                        
                                                                    Databases
                                    
                                            14
                                        
                                                                    DNS (Name Servers)
                                    
                                            17
                                        
                                                                    Domains
                                    
                                            4
                                        
                                                                    Email
                                    
                                            8
                                        
                                                                    Files
                                    
                                            6
                                        
                                                                    FTP Programs
                                    
                                            11
                                        
                                                                    Hosting Record How-to
                                    
                                            2
                                        
                                                                    Installing Software
                                    
                                            3
                                        
                                                                    Introduction to Web Hosting
                                    
                                            8
                                        
                                                                    Logs
                                    
                                            1
                                        
                                                                    phpMyAdmin
                                    
                                            14
                                        
                                                                    Security
                                    
                                            5
                                        
                                                                    Softaculous
                                    
                                            10
                                        
                                                                    SSL Sertificates
                                    
                                            1
                                        
                                                                    Various
                                    
                                            25
                                        
                                                                    Was Your Site Hacked?
                                    
                                            1
                                        
                                                                    Web Hosting Glossary
                                    
                                            1
                                        
                                                                    Where do I go?
                                    
                                            1
                                        
                                                                    Categories
Basic tar usage Print
- 517
Was this answer helpful?
Related Articles
                            
                    
                    Internal server error with 777 chmodded folders and files
                                        For PHP applications to access MySQL databases or upload (write) files to site folder(s), the...
                
                            
                    
                    Can I host adult content on your web hosting?
                                        Yes, as long as it's legal adult material (no child porn or weird things).
                
                            
                    
                    Can you install a script on my account?
                                        Yes, we can install any standard script for a one time fee of 15$. Most scripts can be...
                
                            
                    
                    Can you transfer my website from my old web hosting company?
                                        For us to be able to move your website from your old web hosting company we will need the...
                
                            
                    
                    Do you do backups?
                                        Yes, daily on all shared and reseller accounts!
Vps and dedicated server's backups are client's...
                
                    
     
					 
 