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.

Change Your Hostname

In today’s article, we’re going to learn how to change your hostname in Linux. It’s a pretty easy article to follow along with, so even if you’re a beginner you can follow along. If you’re an advanced user, you probably already know how to do this. If not,  you will now.

So, what is your hostname? Basically, it’s the name of your computer (generally speaking). You login as <your_username> to a computer referred to by its <hostname>. So, in this case, I’m currently kgiii@kgiii-lmde. The ‘kgiii-lmde’ is the hostname. When you open your terminal, in all likelihood it shows you the <user>@<hostname> at the start of your regular prompt.

You can do some neat stuff with the hostname. For instance, and depending on the distro, it’s often local or localhost, you can connect to your LAN devices (without knowing the IP address) by connecting to <hostname>.local. This is handy for using SSH around the house, or even for using FTP or whatever.

If you don’t know your hostname, you can use one of the following commands to figure it out:

Or you can try:

There are other ways to show the hostname, but those two should be enough to get you sorted out. Either of them will happily spit out the hostname. Now that you know your hostname, it’s time to learn how to …

Change Your Hostname:

Like so many other articles on this site, this one requires an open terminal to continue. So, just press CTRL + ALT + T and your default terminal should open.

With your terminal open, enter the following command:

That should permanently change your hostname to the new hostname you chose to use in the command. You can actually change it temporarily, it will not be persistent between reboots, with the hostname command. to do that you’d just sudo hostname <new_hostname> and it’ll change it for the current session only.

To verify that you’ve changed your hostname, run one of the commands listed in the preamble section of this article. (Just type hostname and to verify you know how to change your hostname.)

Anyhow, that’s all there is to it. You really don’t need anything more than that if you want to change your hostname in Linux. Anyone should be able to follow the few directions needed.

Closure:

There you have it, another article. To think, we’re over 200 articles now. This is just one more among many, and this one is easy enough to follow. If you ever wanted to change your hostname, now you know…

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.