The following utilities are used to package files together for storage, convenient moving or other reasons.
ar does not recognize a directory structure, so you cannot store the contents of a directory tree in an archived file.
Create a tar archive.
tar cvf mydir.tar mydir
The 1st 3 letters after tar are options, c - create the archive file, v - verbose reporting of archiving process, f mydir.tar - filename of archive destination instead of tape drive. when specifying target directory to archive, the absolute or relative path specified for the target directory will also be stored in the archive.
Extract a tar archive.
tar xvf mydir.tar
The three options are : x - extract the contents, v - verbose messaging, f - file to extract from. When a tape archive is extracted, it will be extracted into and under the current working directory. If an absolute path was used in creating it, tar will create all the directories recorded under the current directory.