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.

Stop People From Viewing Files In A Directory With .htaccess

If you have a website, then you will have directories and you might want to stop people from viewing files in a directory. You might want to do this for privacy reasons, or for security reasons. So, if you’re looking to stop people from viewing files in a directory with .htaccess, you’ve come to the right article.

By using the .htaccess method to stop people from viewing files in a directory, people will still be able to see linked files in the directory – they just won’t be able to browse the directory to find unknown files. It’s like the best of both worlds. They can see what you’ve shared, but (unless guessing URLs) can only see what you’ve shared and nothing else.

It’s a handy tool to use and basic security (and privacy) step to prevent snooping around your server – assuming .htaccess is an option. Of course, if you’re just spinning up a quick Python server, it’s not going to be of much help.

Anyhow, this will be a relatively short and easy article, and only applicable to a subset of the site’s visitors. I want to cover more server articles, so we might as well take this one from the previous site and migrate it to this one. 

Stop People From Viewing Files In A Directory:

Open the directory you want to keep private with your favorite FTP client – unless you’re doing this on a local computer. If that’s the case, you can just navigate to the directory.

Create a new file called .htaccess. The ‘.’ is important and mandatory, as it’s a hidden file. If the file already exists, now would be a good time to make a backup.

The permissions for .htaccess should be 644. Your FTP client will let you set permissions. Locally, you can chmod 644 .htaccess and that should work nicely.

Next, you’ll want to edit the .htaccess file with a plain-text editor to add the following line (if the file already exists, be sure to put this on its own line):

Save the .htaccess file. Be sure not to modify any other lines in the process. There’s a whole lot that can be accomplished using .htaccess and it can be pretty complicated.

What this will do is prevent indexing the files in that particular folder. If people try to access the folder directly, they’ll get a 403 forbidden error. At the same time, you can still link directly to files in that folder.

So, let’s say you added the .htaccess to a directory called /tmp. You can still link to, use, and send people to /tmp/picture.jpg like normal, but people won’t be able to browse the directory and find files you don’t want them to see. They won’t be able to browse the directory to see that you’ve also uploaded picture2.jpg to the same directory.

For more information, you can click this. (I wasn’t kidding when I said it could get complicated.)

Closure:

Thanks for reading today’s article. Today, we learned how to stop people from viewing the files in a directory – unless you let them know the URL, of course. It’s a pretty handy skill to have, as is basic editing of the .htaccess file.

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.

How To: Extract An .rar File

Today, we’re going to learn how to extract an .rar file in Linux. You don’t see .rar files all that often with Linux, but sometimes they crop up. Today’s article will explain how to extract them.

You may recall .rar files from your Windows days, assuming you have a history with Windows – as many of us Linux users do. You’d probably be most familiar with the application known as ‘WinRAR‘. 

While the application is specifically for Windows (there’s a text-based WinRAR for Linux, perhaps a subject for another article), it produces files compressed with the .rar format. The .rar compression is much like any other compression, from .tar.gz to .zip. At some point, you may be faced with opening one while you’re using Linux.

Just because the files are often made with WinRAR doesn’t mean the files will only be opened in Windows. Once in a while, you’ll find something you need that’s in .rar format and you’re using Linux. Well, fear not, you can extract an .rar file easily enough. It’s just a simple terminal command away and you should be all set. While not a skill you’ll need often, it’s one you’ll maybe need and now is a good enough time to learn how.

Extract An .RAR File:

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.

Once you have the terminal open, you’ll need to install an application called ‘unrar’. If you’re using a major distro, it’s likely in your repository – though maybe under the name of ‘unrar-nonfree’. Search your repositories and you’ll find it.

If you’re using Debian/Ubuntu/similar then it’s easy enough – it’s called ‘unrar’ and you install it with:

With that installed, the next part is really quite easy:

That will extract the contents of the .rar file while preserving paths. If you don’t care about that sort of result, just use the ‘e’ flag like this (and it’ll extract everything to the current directory):

You can also extract password protected content easily enough, just read the man pages with man unrar to learn how. Anything you can do with a GUI you can do with the terminal. You just need to read the man page. This article only covers how to extract an .rar file without any complexity.

Closure:

That’s it. That’s today’s article. The goal was to learn how to extract an .rar file in Linux and now you know how to do so with unrar and the Linux terminal. ‘Snot all that complicated, really.

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.

macOS vs Linux: Comparative Analysis

macOS vs Linux: Comparative Analysis

 

BSD code is the base of macOS, which is developed under the banner of Apple Incorporation. The Unix-based operating system is developed with the use of languages like C, C++, etc. In 2001, the first version of macOS was introduced. This OS is in the second position in the world to be used highly on computers.

Linux is independently developed with a system similar to Unix. The systems where Linux plays a crucial role are named mobile devices, cloud computing, servers, personal computers, supercomputers, etc. In 1991, the first version of Linux was introduced to the world.

Linux can be easily downloaded and used. In comparison to Linux, Windows is high in demand and not available for free. macOS is picked up by specific users who can spend a specific amount from their pocket because it is designed by Apple and costs too much. Even though it is not affordable for all Windows users.

Both of these systems are not compatible with binary codes. The applications based on macOS cannot be used like open sources.

To know more about the differences and similarities of these operating systems, please have a look over the listed headings underneath. The doubts that can annoy you when deciding Mac vs. Linux are going to be sorted in the sections mentioned underneath.

Is it good to use macOS and Linux together?

People who have used Linux for years and are now using Apple’s Mac think MacOS is good to go. If you are a Mac user, you can use Mac OS X. To fulfill all your needs with Linux; you need to get another computer. You can look for a cheaper choice where Linux will work.

Is it possible to switch to macOS from Linux?

Yes, it is easy. You need to take care while doing this so that you can avoid data loss or damage. The entire process of macOS installation should be done properly, along with a recovery partition.

 Which is safer – Linux or macOS?

For a few reasons, Linux is considered safe in comparison to Windows and macOS. But, still, there are some flaws and exploits due to which Linux does not stand at the top.

The use of these operating systems depends upon the needs of the user and his/her preferences. If we talk about higher usage of the OS, then it’s only Windows.

Is It possible to install Linux on an old iMac?

Installing Linux into the old iMac computer is not an issue. For this task, you don’t need to take tension as you do not need to use any specific Mac Distro. Any of the distros can be downloaded and installed. a 64-bit distro will be a better choice to make the Old iMac be used with Linux.

If you are not able to download Linux, there might be a problem with your internet connection. Check out https://setapp.com/how-to/fix-your-connection-is-not-private-error to resolve the error.

 Which version of Linux is good to use with macOS?

The free versions of Linux to be used with Mac are — Linux Mint, Fedora, and ArcoLinux. Linux, which is easily accessible to anyone, was created by Linus Torvalds and owned by many authors (as they worked over source codes) with the GPLv2 license.

Drawbacks of Linux OS 

  • No standard environment for the desktop usage
  • No way of proper single presentation for packaging software
  • No proper and good support for games
  • Rare availability of desktop software

Downsides of macOS 

  • Mac does not allow to perform required customization
  • The gaming experiences of Mac users are not good to the date
  • The creation of new files becomes an issue on Mac devices
  • The macOS does not allow to make a jump list like Windows

Is there an issue if Linux dual-boot is being performed on a Mac device?

With Boot Camp, the process of Windows installation is easy on the Mac system. But, this process is not good to go if you want to do this for Linux. It is a tough task to be performed. If you still want to do this, you need to try it with the use of a USB or CD drive.

Why should you go for Linux in comparison to Mac?

Linux is a safer choice in comparison to Windows and Mac. With this OS, you can simply keep the malware and viruses away. The security codes and aspects involved in Linux are helpful in keeping your computer safe. Still, if you want to be more protected, then ClamAV antivirus can be used with Linux.

macOS has always had a specific clientele who love to play games flawlessly, and Linux is being loved by users who are set to program & develop formulas and codes. Choosing any of these OS is not easy, but priorities and specifications can help you to make the right decision.

Backup Optical Media To .iso

In today’s article, we’re going to learn how to backup optical media to .iso. If you have optical disks you want to backup, this is an easy way to go about it. It will not work with all disks, especially those encumbered with DRM.

This is useful for data disks, for example. It’s also useful for music CDs. It’s less likely to be good for things like game DVDs or movies. Those use various methods to stop you from copying your discs. While there are ways to backup some of them, this article won’t be getting into it.

Instead, we’ll just be using ‘dd’ for this exercise. If you’re unfamiliar with ‘dd’, it stands for:

convert and copy a file

If you’re unfamiliar with the command, you should pay extra attention to the way it is used in this article. It’s a powerful tool and using it with just the slightest error can (and will) make you run for your backups.

So, with all those things in mind, let’s learn how to …

Backup Optical Media To .iso:

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.

With your terminal now open, we should probably figure out where your optical disk is. One way to find your optical media drive is with this command:

Inside the results of that command you’ll find something like “[sr0] scsi3-mmc” from which you can glean that /dev/sr0 would be your optical drive. With that information at hand, you’ll fun this command:

Be really sure that the path to save is correct, though this command is less likely to harm you than other ‘dd’ commands.

Anyhow, you can verify the integrity of the file created. That’s an easy enough step to take and looks a bit like this:

That should spit out two numbers. Those numbers should match. If they don’t, then something has gone wrong and you might want to try it again.

Closure:

There you go… Another quick and easy article. This one teaches you how to backup optical media to .iso, a handy skill if you want to preserve the data on the disks before they get worn out, broken, or lost. 

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.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.