How To Use The Tar Command In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The tar command is a basic but powerful utility used to archive and extract files on Linux. It is commonly used to deliver multiple files within a single package or as a backup tool. To use the tar command in Linux, type in a terminal:
tar –cf <archive_name>.tar <source_file(s)>
Where:
–c is for creating an archive –f is for specifying the filename of the archive You can also use the following flags:
–z to compress the archive using gzip;
–j to compress the archive using bzip2;
–p to preserve the permissions of the source files in the archive;
–v to list the files being archived;
—exclude to exclude files or directories from being archived.
For example, to create an archive containing two files called file1 and file2, you would type:
tar –cf archive.tar file1 file2