HomeНаука и техникаRelated VideosMore From: tutoriaLinux

Archiving and Compression on Linux - Basic tar Commands

665 ratings | 30497 views
ARCHIVING + COMPRESSION ON LINUX: tar -zcvf docs.tar.gz Documents/ DECOMPRESS/UNARCHIVE ON LINUX tar -zxvf docs.tar.gz #################### OPTIONS z - gzip c - create archive f - archive FILE (name file) v - verbose x - extract Table of Contents: Compression + Archiving: 04:25 Decompression: 07:01 Don't do this: 09:34 Examples (Wordpress vs. Joomla): 12:19 Explanation of 'tar' options: 14:33 Full Linux Sysadmin Basics Playlist: https://www.youtube.com/playlist?list=PLtK75qxsQaMLZSo7KL-PmiRarU7hrpnwK Check out my project-based Linux System Administration course (free sample videos): https://www.udemy.com/hands-on-linux-self-hosted-wordpress-for-linux-beginners/?couponCode=tl35 Patreon: https://www.patreon.com/tutorialinux Official Site: https://tutorialinux.com/ Twitter: https://twitter.com/tutorialinux Facebook: https://www.facebook.com/tutorialinux
Html code for embedding videos on your blog
Text Comments (53)
Ciprian Hirlea (2 months ago)
I've read a nice article some time ago on how to make this more memorable. tar -czf(compress ze files) and tar -xzf(extract ze files). Great videos buddy and thank you for investing the time and effort in making these
archangeltemjin69 (5 months ago)
I'm grateful that you've covered a two-part tmux video session, on my previous job, I've just used tmux to avoid being disconnected during the execution of the ansible script, but you've taught us here the great power of tmux. Thank you so much, man.
Ahmad El-Komey (8 months ago)
Thank you for the tutorial. I was wondering how did you get the shell to ignore case on suggestion? I mean, you type "d", hit tab and it suggests both "decompression_chamber" and "Desktop". AFAIK, linux shell is case sensitive. I appreciate what you are doing here man.
G O (8 months ago)
Super great series Dave! Thank you. You mentioned ftp and have touched on various protocols in the series. can you recommend a video series on the relevant ones for a budding penetration tester that has the same vibe as yours?
tutoriaLinux (8 months ago)
I haven't come across any, but I haven't been looking hard. Let me know if you find a channel like that!
Jenish Sakhiya (9 months ago)
I'd be like `cat /home/dave/Documents/importantdocs/naughty_sites.txt` or hopefully `cat /home/dave/Documents/importantdocs/naughty_sites.txt | less`
ste h (11 months ago)
Best thing about you mate, you give me something to hook all these facts onto. Ie, you talk about where it comes from. Tar = archiving and compression, they're not the same thing, and here's where it comes from, and some background about ftp...that is what people need in order to learn and retain knowledge. Most people aren't rainman, they can't just read an entire manual of dry technical data and then know how to use something. So thank you and bravo, this is what I need, and I think, what a lot of people need.
Hussein Mahmoud (11 months ago)
Hi thanks for your help when i try to use Tar command i get this error tar: Removing leading `/' from member names tar: /Demo: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors i don,t know what is the wrong with that
Hussein Mahmoud (11 months ago)
i get the solution for this problem if you face this message it means you must change the owner of the file or folder and then try to use the Tar command and it will work without any problem
jimkats1 (1 year ago)
Great video. I recently started watching your playlist of beginner sysadmin tutorials, to improve my knowledge of basic Linux usage and so far I learnt some basic stuff I didn't know. Now I'm coming closer in knowledge to a friend of mine who works as junior sysadmin :D. So, for this video, another useful thing you could explain is how to view the content of an archive file without extracting it. I didn't know how to do it, so I tested and found this: tar -tf test.tar.gz (this will list all the files with their relative path) tar -tvf test.tar.gz (this will list all the files in the same way as running ls -l)
Mateo (1 year ago)
how do you tree your directory.. I don't have that command
Jonathan Ricketts (7 months ago)
@MateoYou have to run it through sudo.
Mateo (1 year ago)
I tried this, but it doesn't seem to work. I am running linux on my mac and a $ sign appears after my name. I think this requires a different installation type... any thoughts?
tutoriaLinux (1 year ago)
It's usually not installed by default. Just install tree and you should be good to go.
Lore staj (1 year ago)
Videos are only getting better!
Nagios Test (1 year ago)
I love that joke :)
Cory Ziegler (1 year ago)
My tar habit is already sufficient for killing herds of sheep.
horatio h (1 year ago)
very well done my friend..can 'like' and 'subscribe' but I can't stand fakebook or twitter I'm afraid..
tutoriaLinux (1 year ago)
That makes two of us :-D
Talkyn (1 year ago)
You can leave out the z when unarchiving, as tar will auto decompress these days.
chinni chinni (1 year ago)
I'm not able see decompression_chamber directory how can i extract
Talkyn (1 year ago)
chinni chinni that was just a directory Dave created to demonstrate extracting the archive. He named it with his typical sense of humour. In other words, you can run tar commands anywhere, but it is often nice to stick a bunch of related tars in a directory somewhere before unpacking them.
Ol' Bluelips (1 year ago)
lzma compression is great
Flankymanga (2 years ago)
I guess you can tell tar to extract to a specific folder explicitly?
tutoriaLinux (2 years ago)
I believe it's the -C option (create): http://linuxcommand.org/man_pages/tar1.html
J Thomas (2 years ago)
The tarbomb bit got me wondering what would happen if the tarbomb had a file called file.txt and you already had a file in the directory you was extracting into with the same name. Turns out it overwrites it! :O
RPBCACUEAIIBH (2 years ago)
Yeah that scenario sucks... I was thinking it's easy to clean up with a script that unpacks the tarbomb safely, and deletes all the shrapnel, looping trough the file list, but that still wouldn't recover you your file... that's why you really need to have backup...
J Thomas (2 years ago)
Ah thanks, right back at ya. FYI I bought your udemy course, keep up the awesome work!
tutoriaLinux (2 years ago)
I love this -- you weren't sure how something would behave, so you tested it for yourself to find the answer. *Almost no one does this,* but it's one of the ways that you can guarantee that you'll actually retain that practical knowledge. Just wanted to thank you for doing that, and then posting the answer here for others to benefit from. You rock!
Likithe Weerasinghe (2 years ago)
Very helpful set of commands. I shall try this from now on. Thanks a ton.
DEEN BANDHU (2 years ago)
Nice way to explain.. sound is neat and clean
BH4T (2 years ago)
thanks so much ur the best boss
Eve (2 years ago)
Thank youu so much, I subscribe at once :)
cswann8 (2 years ago)
I totally LOL'd at the "naughty_sites.txt" My list of adult content is slightly less conspicuous.
EnderCrypt (1 year ago)
not_naughty_sites_TOP_SECRET_PLS_NO_OPEN.txt
allyn barnes (1 year ago)
it just got me REAL damn curious... lmao
tutoriaLinux (2 years ago)
People like you are the reason I do this :-D.
tar -Jcvf docs.txz ~/Documents tar -Jxvf docs.txz
croadjar (3 years ago)
I already know pretty much everything in your video's, but I still enjoy watching them. Keep up the good work!
Limpep (3 years ago)
Is it possible to view the content of a archive before decompressing it?
Limpep (3 years ago)
+tutoriaLinux Thanks tar -tf <filename> seems to do the trick.
tutoriaLinux (3 years ago)
+limpep Sure: tar -ztvf file.tar.gz -- make sure to check out the manpage and Google around for what you want; tar can do a million things.
Soham Gumaste (3 years ago)
How do you get that pretty looking terminal?
Knack Wurst (3 years ago)
+Soham Gumaste Were you refering to cmatrix ? it was the first thing I grabed.
Soham Gumaste (3 years ago)
@tutoriaLinux Thanks for the reply!
tutoriaLinux (3 years ago)
+Soham Gumaste I use i3 as my window manager on all my work machines, along with ZSH (the Z shell). Search for oh-my-zsh to get started :-).
Andy (3 years ago)
What shell are you using?
tutoriaLinux (3 years ago)
+Andy Rhine ZSH (the Z shell), along with oh-my-zsh (check on github).
How to Tech Channel (3 years ago)
awesome video!! I was unaware of the tar bomb inconvenience, I'm going to have to remember that next time I tar something
Ryan Watson (3 years ago)
Thanks
David Bok (3 years ago)
Thanks a lot.
Vincent Renier (3 years ago)
Thank you for the video
CerealKiller (3 years ago)
I needed this

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.