Alright folks, today in this article i'm going to show you how to create a zip file and uncompress/unzip a zip file on ubuntu. This is a beginners tutorial dedicated to my friend michael who asked me about this.
To make this simple, first i want you to open up command line/console/terminal on ubuntu by pressing CTRL + ALT + T, you will see something like this:
Okay, now i want you to create a folder called 'my_ubuntu_folder' and one text file called 'my_ubuntu_file.txt'. The folder and the text file will be use on this tutorial.
Use this command to create the folder
mkdir my_ubuntu_folder
Use this command to create the text file
echo "ubuntuhowtotips.blogspot.com" > my_ubuntu_file.txt
Now, copy the text file into the folder
cp my_ubuntu_file.txt my_ubuntu_folder/
So now we have one folder called 'my_ubuntu_folder' which contains text file called 'my_ubuntu_file.txt' and we also have the text file outside the folder as well.
How to create a zip file on ubuntu
Let's begin with creating a zip file from the text file and folder that we just created, to create a zip file (compress file) we use the 'zip' command, like this:
let's try to create zip file for 'my_ubuntu_file.txt', run this command:
That command will create a zip file called mydata.zip which contains my_ubuntu_file.txt inside, of course you can change the zip file name into something else like myfile.zip, file1.zip, etc it doesn't have to be mydata.zip.
So how to create a zip file from a folder? all you have to do is add -r parameter and specify the folder name, zipping/compress a folder into zip is the best way if you want to create zip file for multiple files.
let's create zip file from folder 'my_ubuntu_folder', here's the command:
That command will create a zip file called myfolder.zip which contains folder called my_ubuntu_folder, the folder itself contains a file.
How to unzip/uncompress a zip file on ubuntu
Okay you already know how to create a zip file, now we are going to unzip it (uncompress the zip file). To unzip/uncompress a zip file we use the unzip command:
Unzip on the same location
Unizip on different location
How to create a zip file on ubuntu
Let's begin with creating a zip file from the text file and folder that we just created, to create a zip file (compress file) we use the 'zip' command, like this:
zip [name-of-the-zip-file] [the-file]
let's try to create zip file for 'my_ubuntu_file.txt', run this command:
zip mydata.zip my_ubuntu_file.txt
That command will create a zip file called mydata.zip which contains my_ubuntu_file.txt inside, of course you can change the zip file name into something else like myfile.zip, file1.zip, etc it doesn't have to be mydata.zip.
So how to create a zip file from a folder? all you have to do is add -r parameter and specify the folder name, zipping/compress a folder into zip is the best way if you want to create zip file for multiple files.
zip -r [name-of-the-zip-file] [the-folder]
let's create zip file from folder 'my_ubuntu_folder', here's the command:
zip -r myfolder.zip my_ubuntu_folder/
That command will create a zip file called myfolder.zip which contains folder called my_ubuntu_folder, the folder itself contains a file.
How to unzip/uncompress a zip file on ubuntu
Okay you already know how to create a zip file, now we are going to unzip it (uncompress the zip file). To unzip/uncompress a zip file we use the unzip command:
unzip [name-of-the-zip-file]
unzip [name-of-the-zip-file] -d [unzip-on-different-location]
Unzip on the same location
unzip mydata.zip
unzip myfolder.zip
Unizip on different location
unzip mydata.zip -d ~/Documents
unzip myfolder.zip -d ~/Documents
Unzipping/uncompress zip file is pretty simple, and if you want to unzip to another location, just simply put -d parameter followed by the path of any location you want.
No comments:
Post a Comment