EX200 Red Hat Certified System Administrator RHCSA – The Red Hat Linux file system explained and basic functions Part 2

  • By
  • January 18, 2023
0 Comment

4. Backups part 2. How to uncompress files and restore backed up files

Welcome back, all. Today I’m going to go ahead and show you how to actually uncompressed things and how to restore your backup files. Before I do so, I owe you an explanation from the last tutorial that I got entangled with. Well, here it is. Basically, the quotation marks were a problem because then the exclamation mark knew that it was interpreting it as some sort of a command or something of a kind like not, because it generally represents not. And that’s why it said it does not recognize the command or something. That’s why I got that error. You see, if I go ahead and type in quotation marks, there you go. Bash event not found because of the exclamation mark.

And if I go ahead and remove the quotation marks like this and press Enter, you see, I’m going to append it, append the file to the last line. And if I type in the escape character here and if I press Enter still, I am going to get exactly the same thing without any problems of whatsoever. You can keep on doing this until I run out of this space, but I wouldn’t want to bore you to death. So let’s go ahead and jump into the subject at hand today. As I said, we’re going to be dealing with unpacking the files that we’ve actually backed up. But let me just see. Besides Echo, I’m sure I have it here somewhere so I don’t have to type the whole command in again. There we go. These are the two commands that I want to use. And you see, I have used the commands that we’ve learned previously in order to provide myself with such an output. I’m sure you’re familiar with them by now.

The line that we should be paying attention at is this last line. I have left the first line deliberately so that we can do a bit of comparison. This command we will use to actually extract and unpack everything from this file into something else while we use this command. Oops up. It’s running away. The terminal lines are running away while we use this command in order to package the contents of this file into this file. Anyway, here, down below you have X, which stands for pull it out of Tar. V for Bose p preserve permissions as before, Z, treat it as a Gzip up here as well, except up here it will compress it, and down here it will uncompress it. F for file. And then we pass in the file name. And right next to the file name, we’re going to add another argument, which will be minus sign, capital C, and then a path to where we actually want to extract these things. Now, for myself, I have created a folder. It’s called sheep. So I have a folder called Sheep right here. I could have named this folder anything I wanted to. Originally, I named it Recovery or something of a kind.

But then the name didn’t really resonate. It didn’t feel right, so I renamed it to Sheep. Anyway, we are going to extract it. But before we do, before we do, suppose that you have a lot of these backup files here. Some of them you made, some of them you didn’t. Some of them are made by the system, some of them are made by some other person out there. And you are required to restore a backup for a certain system. But you can read the names or you can read the names of these backup files, but you’re still uncertain as to what is contained within.

How do you suppose you would have a look inside without actually performing the extraction itself? Well, let’s consult with the man pages. That’s always the number one source of these things and I could have shown you that straight away. But I want to show you one more thing in the man pages that you can use it in a similar fashion, like Vim. Just press semicolon and then type in commands here. For example, you can type in Search and then what shall we search for? Well, you shouldn’t type in Search, but this is how you would conduct a search. What shall we type for? Let’s type in list. Excellent. So this is exactly what we have been looking for. The second find of List is what we need. Under examples, you have tarspacedvfarchive. Tar. What does it say?

What does this do? It says List all files in archive, tar verbosely. And we can remove the verbose output here as well. But I’ll show you what I mean by that. Let’s go ahead and clear. Type in Tarspace TVF Backup press center and they’re going to get listed. So you’re going to get the permissions here as well. But I don’t know, most of the time I would say that I you don’t need to see the permissions here to figure out what is in the file and the dates. It is far more useful well, dates maybe, but it is far more useful to actually have a look at the contents of the folder at the contents of the Tarball. The reason why I say dates maybe is because most of the backups, when they are made, the dates, the exact date, the exact time when the backup was made can usually be seen in the name of the backup straight away. That’s how they are usually made.

I will show you this as we progress through this chapter and as I show you the cron jobs and the automation and creating a bash script for an automated task and so on and so forth. But for the time being, just know that it is so let’s go ahead and clear the screen and let’s remove the reverse output because we don’t want to see all of that. We just want to get a general overview of what is contained in this particular tarball. Press Enter and there you go. This is a this is a much cleaner output here. We can actually see the folders here. We can see the files, and we can generally conclude what this is. Is this what we need or not? But you cannot see pretty much anything else besides the folders, files and stuff like that. The things that you see in front of yourself, you could basically list up to the top, but the output is the same.

You just have the paths here and that’s it. Okay, so let’s go ahead and clear the screen. Once again, let us call the file. Now, let’s try to actually unpack some of this particular Tarball. We will unpack this tarball and extract it into the folder. Sheep, I encourage you to make your own folder. Just type in MK, dear, and then name it. Yeah, name it. Basically name the folder whatever you want. Whatever. Excellent. Just type in a name here and make a folder. That’s it. Just press enter. It will be created. I have shown this in the previous tutorials as well. That’s why I’m not dwelling on the Mkdir as much now, in case you skipped a few. So type in Tor space minus Xvpz, f space, backup space, sorry, c, capital C. And we’re going to put it into Sheep. Press Enter.

There we go. It’s doing it. It’s doing it. It’s done. Let’s go into sheep. LS. There you go. We have a home directory. Let’s go into home. Let’s do LS. There you go. We have random guy. Let’s go into random guy. LS. There you go. We have all of these files preserve. This entire structure remains as it is. It is all there. Nothing has been left out. Even if I do LSA, you will see that all of these other things have been preserved as well. So they have all been saved. This is a full backup of that particular folder, of those particular files. Anyway, I hope that it is clear in case it is not. The discussions are always open to you. I do check them, I do look at them, and I do try to answer all of your questions with as much clarity as I can. So feel free to ask if you do not understand something, or if you fail to understand something. No shame there. Just ask away and I’ll be more than happy to help you all out as much as I can. Now, I bet you all farewell and until next time.

5. Backups, recovery, and compression part 3. More about tar

Welcome all to this tutorial. Today, I’m just going to continue talking about Tar. I know that the subject can be a bit tedious and perhaps a bit tiresome from time to time, but it is one of those vital things that you do need to know. And it will be expected of you as a network administrator, as a system administrator, to know these sort of things. Anyway, I won’t bother you for much longer, promise you, with Tar. But there are a few more things which we really need to go over. So one of those things is the fact that you do not need to compress files. I have already mentioned that in the previous tutorials. But let me just demonstrate it for you. And so you can see what is the difference between an uncompressed Tar ball and a compressed Tarball. Let’s go ahead and type in LS here in our home directory. Type in tar CVF space. Shall we name this? We shall name this tar ball. Such an original name. I know. Tar space. And now we can put things into it. We just specify the things that we want to place into it. These are files that I’m putting into it. I can also put folders.

No problems here. Just take a look. And then there we go. Nothing else really needed. I think my Tarball is going to be satisfied with what I have to give it. Press Enter. Excellent. So this has all been placed into my beloved Tarball. Let us verify. Let us just do ll Space. LH Tarbo. Tarboop starball t tar. Okay, so I did mess up my language there, as I was trying to say something that I was trying to type, which is never a good idea, but take a look at the screen. Take a look at the command that I have written. I have used Ll Space lhspacetarballtar. Now, can anyone doesn’t think about it and see if you can actually figure out why is this here? What will that what will these two arguments do? Take a look at the age and try to remember, what do we use H for with LS or Ll? Press Enter. And in case you didn’t figure it out, here is your answer. 28 megabytes. Without this, we would just get a size in Kilobytes and we do not want to actually convert that. So this is an unpackaged Tar ball and it’s 28 megabytes.

However, now we want to we now we want to compress it. And let’s use bZIP. bZIP two, actually. Tarpall. Tar. Press center. It should finish sometime today. Hopefully any moment now, please. There we go. Let us use the Ll command once again. Oh, yeah, sorry. Now it’s bZIP two. And take a look at the file size. It’s unchanged for these small files. I have no idea why, but it seems to remain unchanged. It should have at least minimized it somewhat. LS tarbowl. Tar. Now, the file is way too small. Let’s try doing this again, but with a bigger file. So let’s do RN tar ball might have messed something up, but let’s see if we actually gather up a bigger file into our tarball CVF. And how should we name this one? Well, just name it. No big deal there, and let’s just go ahead and put whatever we can. Or there is a neat trick where you put a dot and press Enter. Now file archive not done. Now, does anybody know what I’ve done here with a dot? See, the dot was the last time. Instead of a dot here, I have given it a list of folders and files. But does anybody know what I’ve done with the dot here? Try to pause the video and figure it out. But if you don’t feel like it, it’s okay. The dot represents your working directory. Double dot is the previous one and dot is the current one. I have placed the sum total of the current working directory into my tar ball here. We can actually verify it quite easily. Actually, I don’t need V. I’m just going to put F and tarball tar. There you go. You see, you have pretty much the whole home directory here. Every single thing.

I mean, it’s a considerably bigger folder than the previous one, I can tell you that much. If I type in Ll space, LH space, tarpall, tar press center, you can see that it’s 65 megabytes as opposed to 28. So there is a significant difference there. Let’s try compressing it one more time. So bZIP, two tarpall, tar, press Enter and wait for it. I have a notorious habit of actually not realizing what I’m zipping or unzipping. So I just type in B unzip or B or G unzip. And that can be a problem sometimes. That’s no big deal. Of course not. There we go. And there you go. Now you actually can see the difference. This one is 65 megabytes, and this one is 42 megabytes. Interesting. We have successfully trimmed it down. How much did we trim down? A third. Basically, we have taken off a third of the file size. Okay, four megabytes. To be honest, if the files are megabytes, this is completely irrelevant. This is a pointless procedure. Okay, granted, you have reduced the file size, but for a couple of megabytes on today’s hard drive, yeah, you haven’t really done much. But keep in mind that with this exact same command, you can pretty much compress save, roll up the entire SQL database or the entire Web server or something of a kind.

Or even the entire file server. You can have, I don’t know, maybe two terabytes of movies, something like that. And if you want to put them into one tower ball, compress them, something like that, this would be significant. Imagine if you could reduce the file size of 900gb by a third. So a third of 900gb should be 300 gigs and if you can remove 300, I don’t think you’re going to remove 300 gigs, just to be honest. But if you can even remove something even close to that, that’s a huge success. I mean, you will already save Gigabytes say that’s a considerable amount of space that you’ve managed to save. Anyway, if you there’s also another neat trick which allows you to unpack a tarball without actually pulling things out of the tarball. You can still leave the tarball as it is. You can still leave the tarball as it is, as I said, but you can just uncompress it. And now that now that we see the size, now it was 65 before, now it’s 42. Let’s go ahead and type in B unzip two tar ball. Press Enter.

I just need to wait for it a little bit, maybe. I think it’s a bit slow because of the virtual machine or something of a kind, but that’s the that’s the difference between these different compression methods. I’ll just get into that in a moment. Up. There we go. You see, the BZ two has disappeared, and it is once again 65 megabytes. Now, before I actually call the tutorial here, I do want to explain a bit of a fundamental difference in between bZIP, zip, Gzip, and maybe you can put in seven zip there as well. The commands, they’re pretty much the same. You just type them like this instead of B unzip two. Pretty sure just write g unzip or something of a kind, and there you go. It is G unzip, but you also have seven zip and you also have zip. Now, you can install those onto your system and let’s just compare them a little bit. bZIP has the best compression ratio, but is very expensive in terms of CPU time and memory usage. Gzip is less expensive, but it doesn’t have quite a good compression ratio as bZIP.

If you don’t understand what a compression ratio is, well, let me put it in simpler terms. Basically, this went down from this went from 65 megabytes to 42 megabytes. And I don’t know, with zip, it would go maybe from 65 to 50 something, something of a kind. Don’t hold my word. It would go from 65 to 50 something. But you get the idea. The compression would not be as effective with zip as it would be with bZIP. Anyway. bZIP and Gzip, they’re not quite expensive, but Gzip is significantly better than zip. And then you have seven zip, which is a compromise. So to say seven zip is not that expensive on the resources, but it does have a relatively good compression ratio, so it should work fine. But I would definitely recommend using bZIP two, actually, if you can spare the CPU and Ram to do it, even for a smaller file like this. But granted, okay, this is a virtual machine. Take that into consideration. It has taken a little bit of time for it to actually complete the action. Anyway, I bet you all farewell. I wish you a ton of luck, and I hope to see you in the follow up tutorial.

6. Automating tasks with cron part 1. Meet the crontab and schedule tasks

Hello everybody and welcome to the tutorial. Today I’m going to go ahead and start talking about Cron jobs which is tied basically to backups as well because if you want to perform daily backups or weekly monthly backups you’re not going to go ahead and sit down and type that every same command every day or every month or something of a kind. No, you’re not going to do that. Rather instead what you will do is schedule a task and state that it should repeat itself. You can basically say repeat yourself every minute. However, take a look at this format that I’ve written out here for you. Here we go. This is a format which you would use in order to edit a Cron tab. In Chron tab you would specify specific time intervals. When do you want a certain command over here to actually run? Now I have given a direct command here although I would advise against it rather instead I would suggest giving a link to a Bash script and then from there run a set of commands or something of a kind.

We will get into that and we will get into the Chrome tab and we will do all of that for the time being. I just want to explain to you what it is used for and what format will it accept primarily because crown Jobs well that’s a standard basically I would say primarily because it is used on pretty much every Linux distro out there as far as I know. Maybe there are some other task automation systems. There probably are but I’m not really sure. I haven’t really seen any and I haven’t really used much of them. I’ve just used chron tab. As it is it pretty much satisfies all of my needs and it’s fantastic because it is also used by system administrators on servers. It’s a text based tool, a terminal based tool, and it requires minimum resources, although you can definitely load it up to, let’s say, repeat something every minute that can and you can have, like, I don’t know, 50 tasks that repeat every minute that can be that can burden a system or something of a kind.

But generally you would never do that. And the format that it accepts is very efficient. So you have minutes here and minute range goes from zero to 60 as you might have guessed. Now as far as the hours are concerned you don’t have A-M-P-M anything of a kind. Forget about those things. You have from zero to 23. That’s it. Now next up, can you guess what this is? I mean if this is a month in the middle so this is a month it goes from one to twelve. And what is this that goes from one to 31? Well it’s day of the month. The range of days can go from one to 31 and on the right side of the month so this is the month from one to twelve. This is the left side day of the month, and on the right side from the month, what do you think this is? So day of the week, they go from zero to six. You have seven digits here from zero to six, including zero. So 0012-3456. Anyway, over here, the last thing that you need to enter here is your command. So you can set up a command as I have.

I have typed in echo, I am alive. So imagine your computer printing this out at an unknown date. Just you see it on your screen on your terminal and says, I’m alive. It can freak you out, but hey, why not? Anyway, that would be the format that Cron accepts. And if you remember the previous tutorial, of course, we’ve done a lot of backup. We’ve covered how you can actually perform a backup. Well, here where it says CMD. Here you would actually type in that backup command. Or even better, you would give a link to the script, to the Bash script. And then that backup would be performed either hourly or monthly or weekly or whatever suits your particular needs. So it would work. Anyway, there is one more thing before I wrap this introductory tutorial to Cron jobs that I would like to share with you. Now, in VI, there is also a very neat functionality.

Okay? VI has a lot of neat functionalities. It has practically an infinite amount of options. But I am in VI. Now, here, let me just exit to show it to you right quick. Look, if I type in Vim context now, this is going to come in handy when writing Bash scripts and when issuing command. In the follow up tutorial, you should notice if I go into the command mode and if I press a colon, as we did before, I type in an exclamation mark. Now, I can type in commands. And some of you might say, well, yes, we’ve done the commands already. Well, yes, but you’ve done the Vim commands. However, with an exclamation mark, you can type in commands such as LSpace tilda. And this is going to list the contents of my home directory. Take a look here.

These are the contents of my home directory. Press Enter and you’re back in VI. You do not need to exit VI to actually browse the file system and to take a look where is what strange. I know. And you can also issue other commands. I would encourage you to experiment with this a lot. All you need to do is enter command mode. So once again, type in an exclamation mark and then type in a command. You can pass arguments to that command, try different things out and see what do you get? Not bad for actually figuring finding things out and figuring what is where. I wonder if man four LS is going to work. Yes, it will. So you see, you can actually access man pages while writing script of a sort to run on your system. So if you’re confused about something, if your answer how something works, you can actually visit man pages and from there figure it out. Very in handy, right? Incredibly useful. Anyway, I would like to bid you all farewell and I hope to see you in the follow up tutorial where we will deal further with task automation.

Comments
* The most recent comment are at the top

Interesting posts

The Growing Demand for IT Certifications in the Fintech Industry

The fintech industry is experiencing an unprecedented boom, driven by the relentless pace of technological innovation and the increasing integration of financial services with digital platforms. As the lines between finance and technology blur, the need for highly skilled professionals who can navigate both worlds is greater than ever. One of the most effective ways… Read More »

CompTIA Security+ vs. CEH: Entry-Level Cybersecurity Certifications Compared

In today’s digital world, cybersecurity is no longer just a technical concern; it’s a critical business priority. With cyber threats evolving rapidly, organizations of all sizes are seeking skilled professionals to protect their digital assets. For those looking to break into the cybersecurity field, earning a certification is a great way to validate your skills… Read More »

The Evolving Role of ITIL: What’s New in ITIL 4 Managing Professional Transition Exam?

If you’ve been in the IT service management (ITSM) world for a while, you’ve probably heard of ITIL – the framework that’s been guiding IT professionals in delivering high-quality services for decades. The Information Technology Infrastructure Library (ITIL) has evolved significantly over the years, and its latest iteration, ITIL 4, marks a substantial shift in… Read More »

SASE and Zero Trust: How New Security Architectures are Shaping Cisco’s CyberOps Certification

As cybersecurity threats become increasingly sophisticated and pervasive, traditional security models are proving inadequate for today’s complex digital environments. To address these challenges, modern security frameworks such as SASE (Secure Access Service Edge) and Zero Trust are revolutionizing how organizations protect their networks and data. Recognizing the shift towards these advanced security architectures, Cisco has… Read More »

CompTIA’s CASP+ (CAS-004) Gets Tougher: What’s New in Advanced Security Practitioner Certification?

The cybersecurity landscape is constantly evolving, and with it, the certifications that validate the expertise of security professionals must adapt to address new challenges and technologies. CompTIA’s CASP+ (CompTIA Advanced Security Practitioner) certification has long been a hallmark of advanced knowledge in cybersecurity, distinguishing those who are capable of designing, implementing, and managing enterprise-level security… Read More »

Azure DevOps Engineer Expert Certification: What’s Changed in the New AZ-400 Exam Blueprint?

The cloud landscape is evolving at a breakneck pace, and with it, the certifications that validate an IT professional’s skills. One such certification is the Microsoft Certified: DevOps Engineer Expert, which is validated through the AZ-400 exam. This exam has undergone significant changes to reflect the latest trends, tools, and methodologies in the DevOps world.… Read More »

img