untar Command in Linux
Build an AI-First Career, Master the Complete Skillset
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
AI Forward Deployed Engineer Program
Full-stack engineering, production AI and client-facing consulting
+1000 moreOverview
In this article, we'll explore the untar command in Linux, which is primarily used to extract files from tar archives. The tar command is widely used for backup and archiving purposes, as it can package multiple files into a single tarball. The untar command can help you to decompress and extract the files from these tarballs.
Linux untar Command Syntax
The syntax for the untar command is as follows:
Where:
- options: These are flags and options that determine the behavior of the tar command.
- archive-name: The name of the tarball to be processed.
untar Command Options:
- -x: Extract files from an archive.
- -f: Specify the archive file.
- -v: Verbose mode, display the progress on the screen.
- -C: Change to the specified directory before performing the operation.
Example Usages
-
Basic untar command usage:
Output:
Explanation: The '-x' option is used to extract files, and '-f' is used to specify the archive file.
-
Untar with verbose mode:
Output:
Explanation: The '-v' option enables verbose mode.
How Scaler Transformed Careers in Different Fields
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
Tips
-
Always use '-f' option to specify the archive file, as not using it may lead to unexpected behavior.
-
Use the '-C' option to extract files to a specific directory instead of the current directory.
Stop learning AI in fragments—master a structured AI Engineering Course with hands-on GenAI systems with IIT Roorkee CEC Certification
Turn Learning into Career Growth
Advanced Use Cases of untar Command in Linux
-
Untar a gzipped tarball:
Output:
Explanation: The '-z' option tells tar to decompress the gzipped archive before extracting.
-
Untar a bzipped tarball:
Output:
Explanation: The '-j' option tells tar to decompress the bzipped archive before extracting.
-
Untar to a specific directory:
Output:
Explanation: The '-C' option is used to change the directory before extraction.
Conclusion
-
The untar command is used to extract files from tar archives.
-
Various options like '-x', '-f', '-v', and '-C' can be combined to control the extraction process.
-
It's essential to use the '-f' option to specify the archive file.
-
Advanced options like '-z' and '-j' can be used to handle compressed tarballs.
-
The '-C' option allows extracting files to a specific directory.
