Unzip a file
Ubuntu distributions usually include the zip and unzip utilities. If for some reason yours does not, use the following command to install it:
First of all install wget plugin, for downloading any file from internet on my server:
sudo apt-get install wget
Install Zip Unzip Software, for compress or extracting the compressed file:
sudo apt-get install zip unzip
Remember, at the time of installing wordpress or any other cms on ubuntu server, change your directory to html, for this enter the following command:
cd /var/www/html
Now Download a zipped file from internet, for example- we are going to download Wordpress
sudo wget https://wordpress.org/latest.zip
To see the downloaded file, enter the following command:
ls /var/www/html
Now extract the downloaded file (unzip):
sudo unzip latest.zip
For Copy A File
The cp command is the primary method for copying files and directories in Linux. Virtually all Linux distributions can use cp. The basic format of the command is:
sudo cp [additional_option] file target_folder
For example:
sudo cp my_file.txt desired-folder
Copy all files from a folder: Go to the directory, where you want to copy;
sudo cp -r * /var/www/html
where '/var/www/html' is target folder (Where files are located or those files folder which you want to copy).
For delete a file or folder
sudo rm -rf index.html
where 'index.html' is target file or folder
Zip a file
Zip stores relative path names by default. There are several parameter-options available for zip. For that read: the manual (man zip). For a starting this will do.
zip -r archive.zip folder
where:
- -r means "recursive".
- folder - Replace your folder name that you want to compress.
- archive.zip - After compression the file name of compressed file.
To unzip you simply use
unzip my_arch.zip
.tar.gz Compression
Most often you will see .tar.gz endings in linux-world. That's the product of two tools: TAR (the tape archiver) and GZIP (the GNU-Zip). Tar has got the call option to automatically gzip/gunzip files after "taring".
tar -cvzf may_arch.tar.gz my_folder
where
- -c means "create"
- -v means "verbose" (sometimes bothersome and slowing down...)
- -z means "use (GNU)zip"
- -f XYZ declares the name of the output file. (You should chose a helping name like XYZ.tar.gz)
There may also be .tar.bz2 endings. This is the product of the -j parameter instead of the -z parameter: you will choose compression with BZIP2 (-> man bzip2).
To extract you simply use -x (eXtract) instead of -c (Create):
tar -xvzf may_arch.tar.gz