How to use tar command in linux for server backup
Tar is the most conman used command in Linux which provides archiving functionality in Unix Like OS. In this tutorial we will see examples of unix tar command related task.
e.g. How to create , extract and view content using tar command.
Below is the syntax of tar command in UNIX:
tar {options} {name of tar file with .tar extension} {All files and directories to be added}
Below some useful options of tar command in Linux and we will use this options in our example to understand the usage of this option along-with tar command.
Create a tar archive file called tecgeeks.tar for /home/rahul/mydata directory.
here tecgeeks.tar will be created on your current directory, You can specify the location where you want to keep the archive tar file,
#tar -cvf tecgeeks.tar /home/rahul/mydata
Here in below command it will create a tar archive file called tecgeeks.tar for directory /rahul and file /data/linux.txt
#tar -cvf tecgeeks.tar /rahul /data/tecgeeks.txt
To View a Tar files Contains (list file inside a tar)
Run the following command: #tar -tvf tecgeeks.tar
To Extract a Tar file
Type the following command to extract tecgeeks.tar in a current directory:
#tar -xvf tecgeeks.tar
Type the following command to extract linux.txt file from an archive called tecgeeks.tar in a current directory
#tar -xvf tecgeeks.tar linux.txt
Type the following command to extract tecgeeks.tar in a directory called /home/mydata,
#tar -xvf tecgeeks.tar -C /home/mydata
You Can Check My YouTube Video to Understand more !!!! -
e.g. How to create , extract and view content using tar command.
Below is the syntax of tar command in UNIX:
tar {options} {name of tar file with .tar extension} {All files and directories to be added}
Below some useful options of tar command in Linux and we will use this options in our example to understand the usage of this option along-with tar command.
- -c: To Create a tar file
- -v : Verbosely output to show progress
- -f : Point name of tar file to be created
- -x : Extract all files & folders from archive.tar
- -t : Display the contents of Tar file
Create a tar archive file called tecgeeks.tar for /home/rahul/mydata directory.
here tecgeeks.tar will be created on your current directory, You can specify the location where you want to keep the archive tar file,
#tar -cvf tecgeeks.tar /home/rahul/mydata
Here in below command it will create a tar archive file called tecgeeks.tar for directory /rahul and file /data/linux.txt
#tar -cvf tecgeeks.tar /rahul /data/tecgeeks.txt
To View a Tar files Contains (list file inside a tar)
Run the following command: #tar -tvf tecgeeks.tar
To Extract a Tar file
Type the following command to extract tecgeeks.tar in a current directory:
#tar -xvf tecgeeks.tar
Type the following command to extract linux.txt file from an archive called tecgeeks.tar in a current directory
#tar -xvf tecgeeks.tar linux.txt
Type the following command to extract tecgeeks.tar in a directory called /home/mydata,
#tar -xvf tecgeeks.tar -C /home/mydata
You Can Check My YouTube Video to Understand more !!!! -
How to use tar command in linux for server backup
Reviewed by TecGeeks News
on
April 27, 2016
Rating:
No comments: