Unix/Linux : How to archive and compress entire directory ?
While writing tutorial on how to untar a gzipped tar ball archive with Golang today, I was lost at how to actually create a tar ball archive and compress the tar ball. Maybe I'm just getting too old or could't remember the exact command after such a long time.
Therefore I better write a short tutorial on how to use the tar
command to archive and compress entire directory(and sub-directories).
The simplest command to create a tar ball :
> tar -zcvf tarball.tar.gz /directorytoarchive
Basically the command above is to :
-z Compress archive with gzip format
-c Create archive
-v Verbose mode ( more information)
-f Archive filename to be created
So the parameters should look like this :
> tar -zcvf <archivenametobecreated.tar.gz> <directory to be archived>
Just in case that you only want to create tar ball WITHOUT gzip.
> tar -cvf <archivenametobecreated.tar.gz> <directory to be archived>
// just minus the z
flag
Hope this short tutorial is useful for you.
See also : Unix/Linux : How to open tar.gz file ?
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+24.6k Golang : How to read integer value from standard input ?
+5k PHP : Get client IP address
+6.3k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+13.1k Golang : Simple word wrap or line breaking example
+4.4k Python : Create Whois client or function example
+6.9k Golang : Generate human readable password
+7k Golang : Ways to recover memory during run time.
+15.7k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+8.1k Golang : Gonum standard normal random numbers example
+8.8k Golang : Populate slice with sequential integers example
+19.1k Android Studio : AlertDialog and EditText to get user string input example