How To: Zip Files In Lubuntu

Today’s article will be relatively short and fairly easy as we talk about how to zip files in Lubuntu. This seems like a nice and easy article and something folks might want to know. If you’re in this category, by all means, read on!

NOTE: This is written for Lubuntu, but will work in other distros. I’m just trying something new, specifically doing some distro-specific articles to see how well they do.

If you’re unfamiliar with Lubuntu, it’s a lovely distro that’s fairly lightweight and easily configurable. Lubuntu is an official Ubuntu flavor. The purpose of Lubuntu has changed. The focus has changed from being lightweight (which it still is) to getting out of your way. You can read some of the history on Wikipedia’s Lubuntu article.

I’m biased because I’m an official Lubuntu member. I’m on the team that brings you this distro and have written a few Lubuntu-specific articles.

Disable Window Grouping In Lubuntu
Change Snap Application Privileges In Lubuntu
Change Your DNS Servers To Google’s In Lubuntu

(There are more, of course!)

I’m definitely a fan.

Anyhow, we’ll be learning to zip files in Lubuntu today. When you zip a file, you compress the file and make a new file. Some files don’t compress while other files (such as plain text files) can be compressed quite a bit. There are many different compression tools, methods, and algorithms. I’ve covered some RAR stuff in the past, for example.

Zip Files In Lubuntu:

We’ll be using the zip application in the terminal to zip files in Lubuntu. You can compress files graphically, but we’ll be doing this in the terminal. You can do almost anything in the terminal. So, let’s start by pressing CTRL + ALT + T to open the terminal.

The tool we’ll be using is the zip application, defined simply as:

zip – package and compress (archive) files

For the record, the zip application should be installed by default. I don’t like to assume the default is still true, so I’ll also explain how to install the application, also in the terminal.

You can install the zip application with this command:

You can check the man page for zip with this command:

To zip a file in Lubuntu, you would run this command:

If you want to zip multiple files in Lubuntu, you can just add them to the command by tagging them on the end. That looks like this:

See? It’s just that easy to zip files in Lubuntu – specifically in the terminal. Of course, this is true for all sorts of other distros. The only thing that would change would be the process for installing the application should it not be installed by default.

Closure:

Yup… I told you that this would be a quick and easy article. I will actually (probably) cover more of this very topic. It’s a way to keep fresh articles on the site, by being distro/distro-family specific. Yeah, I know that it’s more convenient to have big articles that cover a lot of information. At the same time, writing them all is a lot like work – largely because you start running out of ideas for new articles.

By the way, I could so use a break. You should write an article for me! In fact, you should write a whole series of articles!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Decompress tar.bz2 Files

Today’s article will be simple enough, though it will have limited application, as we discuss how to decompress tar.bz2 files. While this is certainly suitable for a newbie and easy enough to learn, many folks will just choose the GUI route.

Of course, you’re not always able to use a GUI. Sometimes there’s no way to do this graphically and you’ll have to do this in the terminal – perhaps over SSH. In fact, with my crappy bandwidth, I like to upload compressed files and then extract them on the server itself. This sort of thing works for me.

We have already talked about how you go about compressing and decompressing .bz2 files. You can read that article here:

How To: Compress And Decompress .bz2 Files

This time we’re going to be working with ‘tar.bz2’ files – and decompressing these files is different than what you’ll have learned from the previous article.

What is ‘tar’?

A tar file stands for ‘Tape Archiver’ and is a compression method as old as time itself. Well, probably not that long – but a very long time. It’s sometimes referred to as a ‘tarball’ and Wikipedia tells me that it has been around since early 1979.

Here’s a good quote from Wikipedia:

The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization.

The blurb goes on to mention that POSIX has supplanted tar in favor of pax, but when was the last time you saw a .pax file? So, tar is still widely in use.

The man page describes tar as:

tar – an archiving utility

Which is exactly the kind of thing we’re looking for. Imagine that?

What is .bz2?

If you read the link above, you’d know the answer to this question. I assume my readers are creatures of habit, so they’ve done no such thing. They’re probably skipping this section entirely and reading just the middle of the article.

Anyhow, in the previous .bz2 article, I mentioned this:

If you don’t already know, .bz2 files are bzip2 files. You’ll find that bzip2 is an opensource compression program that gets some regular usage, and you’ll sometimes find downloaded files that are compressed with this format. You may also, for compatibility reasons, want to compress files with bzip2 to share with other users who are already set on using the .bz2 format.

That sums it up nicely, though you don’t have to worry about that. See, with this particular command and these particular tar.bz2 files, you can decompress (extract) the files in one fell swoop. 

Just for the record, you should also know that the bzip2 man page defines itself like so:

bzip2, bunzip2 – a block-sorting file compressor, v1.0.8

Your man page might be different, saying that it’s a different version. Either way, that’s what bzip2 is and that’s what it’s used for. 

So, with all that in mind, we can get to the important bits of the article…

Decompress tar.bz2 Files:

As I mentioned in the intro, you can likely do this with your built-in GUI file extraction tool (often file-roller) easily enough. However, again as suggested in the intro, we’ll be doing this in the terminal. In most cases, you can press CTRL + ALT + T to open the terminal.

With your terminal open in the correct directory, you can start by listing the files in the archive without actually decompressing them. That command would look like this:

That will happily spit out a list of all the files included. If you want, you can make the output more verbose by adding the -v flag, so that it’d be tar -tvf for example.

Next, I assume you want to decompress the tar.bz2 files, that is to extract the files within. To do that, you’d want this command:

Finally, I’ll give you a fun command. Let’s say you only want to extract files of a certain type, that is with a certain extension, from your tar.bz2 file. Well, you can do that and it’s easily done. Just use this command:

That command would decompress and extract all the files with .jpg as their extension. You can use any extension there, being sure to use the * to indicate a wildcard even though you already specified it with the –wildcard flag. It is what it is.

There’s more that you can do, but those are the ways I figure most folks are going to decompress tar.bz2 files. Just be sure to check the man page (man tar) to learn more about the command.

Closure:

Well, for better or worse, my articles have been pretty verbose lately. Yes, yes it does tell me how many words are in each article. I’m not sure why I ended up being more verbose lately, but I think it’s a good trend.

Anyhow, today we learn how to decompress tar.bz2 files in the Linux terminal. It’s a useful skill to have and a good tool to toss into your Linux toolkit. You never know when you’re going to need to use these commands, but there may come a time when you do – and you can refer back to this article to learn how.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Unzip All The Files In A Directory

Today’s article might seem like a strange one, but it’s all about how to unzip all the files in a directory. It’s something only a few folks will need to know and something you may not need all that often. However, those folks who need to know this, and those folks who need this often, will be grateful to learn this little tip.

I would think that this will be a short article, as I don’t see it taking up that many words. I’m not sure of the appeal, but I want to write it anyhow. So, if you want to know how to unzip all the files in a directory, this is the article for you!

For me, this is another article based on necessity. See, it’s I who frequently has to unzip a bunch of files all at once. They’re fortunately all in the same directory, making this just a pair of easy commands. Sometimes I have to unzip nested files, so I’ll include the command to do that along with the more simple command that I usually run.

Every month, I get a whole lot of documents from my accountant. For bandwidth’s sake, these get organized and compressed before they’re emailed to me. In theory, I’m supposed to go over them and verify them individually. At best, I open them all up and look at a few of them. I do a sanity check every few months. My accountant is an old lady and I’m pretty confident in her integrity. So, I’m pretty lax…

However, see, I’m supposed to check them… So, I kinda go through the motions and at least look at a few of the documents. That’s where this command comes in…

Unzip All The Files In A Directory:

For those following along, it has been a minute since you needed to open a terminal to follow one of these articles! Well, that wait is over! You know what to do. Otherwise, just press CTRL + ALT + T, and your default terminal should open.

With your terminal open, use the cd command to navigate to the directory that contains multiple .zip files. You should know how to do this, but it’s just: 

Once you have reached the directory you’ve chosen, you can just run this command to unzip all the files in a directory:

Now, sometimes there will be folders inside that directory and those folders will also contain .zip files. To unzip the files recursively you’d just want to use the following find command first, like so:

That lovely command will scour the directory you’re in for sub-directories, enter those directories, and then unzip any files it finds in those sub-directories. It’s not all that complicated, you’re just finding files with .zip in their name and then executing the unzip command on them.

As I said at the start, it’s not one of those things you’ll need often – but when you do need it, you need it. Well, your life is significantly improved by it. I suppose it’s not technically a necessity. You could unzip all the files one by one or even unzip them using a GUI. Still, it’s handy to have.

Closure:

And there you have it. Today’s article is back to a shorter format article, largely because this is what I was thinking about today. Because of that, you got an article explaining how to unzip all the files in a directory – and how to do so recursively – unzipping files nested in sub-directories. You’ll eventually need it! Maybe…

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Zip A Directory In The Linux Terminal

Today, we’re going to zip a directory in the Linux terminal. This isn’t a very complicated task, but it’s worth covering. It’s also not something you’re likely to do every day, but it’s bound to be useful to some of you. You’re eventually going to want to share a directory’s worth of files with someone!

Why zip a directory? This is Linux, we deal with .tar.gz!

Well, in the real world, you might just want to share files with other people. They’ll have no idea what to do with a .tar.gz file – but they’ll know exactly what to do with a .zip file.

More importantly, pretty much every operating system on the planet can open a .zip file. Even way back with the Amiga and Atari systems, you were able  to open .zip files.

As an added bonus, you probably already have the utility to compress files into .zip files and won’t need to install anything! So, you won’t need to install anything and you’ll be able to share the resulting files with pretty much anyone on the planet. What’s not to love?

Heck, you don’t even need to install an application on Windows or MacOS to open .zip files. As a quick test, I can even open them with a file management application on Android. I’m not sure if Android also deals with them by default or if it’s a function of the file manager. Still, you can open .zip files just fine on Android.

With all those great things, you might just as well learn how to zip a directory in the Linux terminal. I promise, it’s really easy.

Zip A Directory:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Chances are very good that you won’t have to install ‘zip’ to get this to work. You can find out quickly enough by just typing:

That’ll likely tell you which zip and where it’s located. If not, you’ll need to install it from your default repositories. I expect very few people will need to do that.

Now to zip a directory…

You can also zip a directory recursively, by using the ‘r’ flag:

This is not to be confused with the R flag, which will recursively compress the files in the folder – but only those files that were specified, such as from this example command in the man page:

That’d take all the files in the current directory that ended in ‘.c’ and compress them into a file called foo. That’s not really what we’re after, nor is it what the article is about. Either way, while you’re exploring, be sure to check the man page. This is one of the biggest man pages you’ll likely come across and there are a ton of options beyond just simply letting you zip a directory.

Closure:

There you have it. You can now zip a directory – such as a directory of pictures to share with your loved ones who are still not using Linux. It’s not terribly difficult, but it’s a useful skill to have and you never know when you’ll want to share a bunch of files with other people.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Unzip A .zip File In the Linux Terminal

Today’s article is going to tell you how to unzip a .zip file in the Linux terminal. It shouldn’t be too complex, nor will it take a great deal of time to learn how to unzip a file.

In the Linux world, we don’t really see the .zip files all that often. We have other ways to compress files, but .zip is still there and you’ll sometimes come across them in your travels.

If you’re unaware, the .zip form of data-compression is actually a ratified standard. The format has been around since the late 80s and is one of the compression methods that supports loss-less compression. There are all sorts of compression formats and methods, but .zip has been around since forever and will probably exist long into the future.

If you want to unzip a .zip in a GUI, I’d say that you need look no further than PeaZip. It’s easy enough to compile from source, or you can find pre-built PeaZip packages for most distros. This article, on the other hand, is how to unzip a zip in the Linux terminal.

It’s not all that daunting and should be a pretty easy article for even a beginner to follow. Though, I suppose, any well-written article should be easy enough for a beginner to follow. Were I something other than a basic keyboard smasher, I’d probably be able to do that!

Read: Decompress a .tar.gz in the terminal

Unzip A .zip:

The headline clearly mentions doing this in the terminal, so you’re going to need an open terminal to continue. That’s relatively simple. Just press CTRL + ALT + T and your default terminal should open.

With your now-open terminal, let’s first make sure you have the ability to unzip a .zip file. To do that, let’s use:

That should return something akin to:

If you do not get a result, you’ll need to install unzip from your system’s repositories. Trust me, it’s in there – unless you’re using a really, really basic distro.

Assuming you get results indicating that you have unzip, it’s actually easy to unzip a .zip in the Linux terminal. You just navigate to the correct directory and run:

Which, I suppose, is mostly all you’re going to need. I should also mention that when you’re attempting to run this command, you can generally type the first few letters of the file name, and then press TAB to auto-complete the file name, saving you some typing time and just generally making the whole thing easier.

Obviously, there’s more to the unzip command. You can check the man unzip page, but the more useful flags will get covered here. Seriously, check the man page. The command is absurdly complex, with tons of options for obscure uses.

For example, to unzip a .zip to a different directory, you just use the -d flag, like so:

If you need to enter the password, you can just use:

When you want to list the files without decompressing them, you just use the -l flag, like this:

If you want to test the ,zip file to see if it’s corrupted, you can use the -t flag.

Normally, it’ll extract the files and overwrite the existing files (if any). You can avoid that with -n flag:

When you unzip a .zip, you will find out that it happily creates new directories. You can avoid that with the -j flag, like this:

Do read the man page! There’s a zillion options.

Closure:

Seriously, read the man page. Learn how to unzip a .zip file – and then all the many, many options included. Of all the man pages out there, this one is one of the most complex ’cause this one little application has a ton of options. Even if you don’t intend to learn it all, read the man page!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.