CompTIA Linux+ XK0-005 – Unit 08 – System Maintenance Part 2
13. Tape Archives Part
Well, now that we’ve talked about compression, the next thing is backup. And that’s kind of what we said we’re going to start with, is talking about doing backups. Now, understand that the compression used to be something we did when we stored files on our servers because we didn’t have a lot of storage room. And then we would back things up with tape, or basically take all of these files, all of these zip files, and put them into what we call a tape archive. We also see many times when people create a tape archive and then compress the archive. So the order is kind of up to what you’re trying to accomplish. Anyway, when we talk about tape archives, we often use the term tar, which was short for tape archive.
In fact, it takes multiple files and packages it into a single file. And often people call that a tar ball, meaning it’s just a balled up package of files. Now, when you do a tape archive, originally the idea was just that you are backing things up to tape. You’re archiving them, and on that tape it is a single backup package. So we can do that without backing it up to tape, which is a way, again, of being able to transfer multiple files by having them packaged as a single file. And then again, if that one single archive is big, you can compress it. And often people start seeing these tar GZ files being sent to them because it’s telling you, look, this is a compressed tarball.
So not only do you have to decompress it, but you have to untar it so you can get all the files out, but it makes for the transfer of information. Very simple. I attach one file, I transfer one file. It’s a smaller file because of compression, and it just makes sense. Now, you can take these packages, these files, you can save them to disk. Like I said, it doesn’t have to go to tape. It can be saved to tape. The original idea behind doing these or any other device that can store a file, USB drive, optical drives, or whatever else you want to use. The command simply is tar and the destination and the source. So tell me what it is I’m Torring up and where it’s going to go.
14. Tape Archives Part
The options for Tarri are going to be many. Some of the ones that you’ll see. The most common are like C for creating the Tar, the F for the input or output file, the T for the list of files in the archive, the V if you want verbose information about the action of creating the archive or taking it out. X to extract whatever is in the Tar and Z to compress or uncompress with GNU zip the actual tape archive. As I said, it’s not uncommon to archive and then compress so that I have as small file as possible and only one file to be able to send to you. You can decompress it, open it up, and then there you have this nice new present. You open the package and you got all these files.
15. Demo – Creating Archiving with tar
All right, so we’re back to our tape archive copied location, the backup tests. I’ve got a lot of log files here that we’ve copied from the VAR log and change the permission, so we should all be good to work with this. And then we’re going to type in the command, target a taped archive with the CVF, and we’re going to call it the log backup so I can’t spell back up. Let’s try that again. Backup tarphile. And we’re going to take all these star logs and put it into that one file. Boom. So there’s all the ones that were put in there. Let’s do an LS LF. And there you can see my new backup. Now I’m going to bed. If I added all of these files up, with the exception of this log backup, that that number to come up to the same value, because I didn’t say anything about the compression, really. So that should have been an uncompressed file that I created by putting it in there.
Okay, so now we’re going to create a compressed tape archive file, and we’re going to give it a little bit different name. We’re going to add that same logbackup tar, but we’re going to add in the GZ at the extension. So I’m going to come over here, and I’m going to say, I want to zip those things. And at the end of the tar, we’re going to call it GZ. Hit the command again. You can see the ones that we grabbed a hold of are the same files, LSL capital F. And you can certainly see that I not only have a tarball, but because of compression, it’s taking a whole lot less space. Okay, so the first one we want to look at extracting. And if I do extract these files, I would use the same tar command, but I use the X for the extraction and again, verbose and all of the files in the logbackup tar file.
Notice I’m not doing this with the compressed file because in this particular case, I haven’t actually said anything about extracting it with the compression. I don’t have the Z option. And there are all those files that were in the tar file, and so those come back out. LS LF. We take a look, and it’s still the same files that we had before, but it’s just the command that you go through to actually do all of that. And in fact, let’s remove just to prove that we actually do it, let’s remove and let’s force the removal of all the star log files. There we go. And now let’s untar that file. In fact, let’s look at the LS. So we have just those two backups. Now let’s untar that file. And now LS LF again, and then they’re back. Okay, so I love my up arrow. You know, I’m saving myself a lot of time.
I’m going to remove all those files up arrow to verify that I only have those two. And I’m going to do the next Tar command I’m going to extract. For this time, I want to decompress verbose all of the files in the log backup tar GZ, and hit the tab key to make that even faster. And I’m really trying to show off all the fun you can have. So now I’ll LS dash LF, and those files are back again. I almost feel like I’m doing a magic trick, you know? Now you see them, now they’re gone. Now you see them. Now the nice thing about that, of course, as a taped archive is I have just a single file to send to you. Whereas in another example, we compressed everything, but we ended up with 810 the same number of compressed files. This case, they’re all nicely packaged into one Tarball. So those are some of the options you have. As far as another way of doing some backups.
16. cpio and find
Now let’s talk about a couple of other utilities that you might want to use. One of them is called the copy in out or the CPIO. What it does basically is it collects and copies files to your standard output. Now the standard output generally might be a printer. It used to be anyway, mandatorily, a printer could also be your monitor or whatever you’re using. Is that standard output? It’s just a way of collecting and copying files so that you can spit them out somewhere. You might even standard out to a backup source. Another tool that we often see is this tool called Find. Now the reason we might use a Find is because we’re trying to find or locate a file that we want to back up with the CPIO. So we use Find to be able to provide information about what is this file is about, what’s in it. It’s a way of saying, okay, find all of the programs that this user owns.
Find all the ones with certain permissions or by this name. Even if you don’t know the full name, maybe you even want to look at it with its last access time or create a time. It’s just trying to find files. That’s all it is. It’s a searching utility. The results of the search could then be fed to the CPIO program. There’s also another type of files like Dump and Restore that allow you to be able to do just what it sounds like. Dump a bunch of data, restore the data. These are just other utilities that you have to be able to help you creating or in creating these backups, these copies, looking for the files you want to find. The more you work with these utilities, the more you’ll see that they have lots of other uses. Like Find, for example, is not used just for backups. We can use Find for a number of different searchrelated needs.
17. Demo – Backing Up with cpio
Okay, we’re going to do a little bit of a backup with the CPIO. So hard not to say C threePO. I know for those of you who aren’t as old as me, that goes back to Star Wars in the 70s. Okay, we’re going to do a find command here real quick to find the home of me. Basically I’m, I’m the user we’re going to search, but it’s kind of straightforward. So I’m going to, to look for in the home directory, in the home directory, the user folder for Trainer. And when I did, boy, just zipped all that stuff right on your screen. So I’m going to pipe it to the More command and it shows me all these files and all these folders and all this stuff, even the hidden stuff that is there for me to back up. So I hit type in Q and we’re going to type all that stuff. We’re going to pipe it instead into those files.
We’re going to pipe that into the little program called CPIO. And when we do that, we’re going to have to create a O output file and redirect that output file to this new location Vartemp. We’re going to call it the backup Oops, the backup CPIO file. So to make sure you understand what we’re doing, we’re going to take the files that we find here. Notice I’m not listing them, I’m finding the files different than listing their name. I’m finding those files, I’m piping it the output to the CPIO that’s going to create an output file, redirecting it to this file in that location and hit enter. Now the more you work with Linux, the more what I just did is going to make sense. It’s a matter of just the flexibility of piping and redirection and all that really kind of cool stuff. Okay, so it took a little bit of time to get all of those in there.
That’s LS now the VAR temp folder, the backup CPIO, and there’s that one file and it’s a pretty good size. In fact, if we did an LS of the VAR temp here, we can see that that’s the only file that we have in that location. Okay, so we’ve done the backup. Now we didn’t do those, we didn’t compress the backup. So we’re going to try kind of that same command. I’m going to edit that command though because I just don’t want to keep typing it. So there’s my up arrow. That brings me up to that previous command and I’m going to use the control b to go back. And what I’m going to do is I am going to use this program CPIO, which by the way, creates a binary file, which means that I probably am not going to get a lot of compression out of it, but I’m going to pipe that to the Gzip C to compress that file and again, using the redirect, send it to a new file.
So look at this control e so I can put in GZ. Okay, so let’s make sure that this is making sense. Again, I’m taking the files with a find command from the trainer folder, piping them into the backup, which is going to pipe that into the ganuz zip. And that finally will result in an output being redirected to a new file that ends in the GZ. So it might actually take a little longer because not only are backing them all up like last time, but I’m also compressing stuff. So let’s find out what happens as we wait. We wait and we wait, and then we’ll take a look at both of those files, and then we’ll also remove them. We’re going to clean up the garbage that we make so that we’re not leaving some backups around that we’re just practicing with.
Okay? So when they’re done, what I’m going to do is I’m going to list both files. I’m going to use a little bit of a wild card to list both the files. There. All right. LSVAR temp. And there they are. They’re both listed. Notice again, not a lot of compression compared to some of the other examples we saw. But that’s because the backup CPIO is a binary file, not a text file. Text files and picture files, for the most part, can be compressed pretty good. This one is a binary. Doesn’t get a lot, but you still have a little bit of savings on space. Okay? And like I promised, we’re going to forcibly remove RM f the VAR temp backup asterisks so get rid of both of those files. And now we’ve cleaned up our mess.
18. Backup with dd Part
All right. Now, another utility that we can use for backup is this thing called DD. Now, I’ve heard some people call it data duplication. Some will call it disk duplication. I’m just going to call it DD. And we use it for not just backing up information. A lot of us use this as a great utility for doing forensic analysis on a hard drive. Now, here’s what I mean. It doesn’t do the analysis. It makes a sectorby. Sector copy of a drive, not just up to the point where the file is located. And this takes you back to a little bit of the understanding of how the hard drive works. A sector is storing a file.
19. Backup with dd Part
Now, if the sector is bigger than the remainder of the file, then the file, we would say, would not fill up the entire sector. Many of your copy programs would just copy the file, leaving all of that, what we would call unused portion of the sector uncopied. Now, having said that, when we do DD, it’ll take the entire sector and copy it, if that’s what you want. Forensics that’s invaluable because you can find fragments of old files that might still be in those other sectors. Now, let me get back on track with what we’re using it here for, which is just backing up your file system. I just wanted to kind of tell you what else we use it for besides just backing up it’ll.
Back up your file system, obviously, your disks, your master boot record. The command line structure is fairly straightforward DD and then you put in if equals the input file of is the output file and then you’re done. As an example, if you wanted to back up the master boot record, the MBR, your input file would be slashdev for device HDA, whatever number it is for that hard drive device. The output file would be whatever destination path you’re going to do, whatever you’re going to call it, MBR, or whatever you want to call that file.
Then you can put in information about the size of each of the sectors and some other options if you want to. But then when you’re done, you’ve got the backup ready to go, you hit the enter and it starts doing the job likewise. The restore is just kind of the opposite. The input file is what was the output file, and the output file was what was the input file? Right. You just switching them around to restore this back together. So DD is a very straightforward program. I would encourage you to practice with it with a couple of the files, a couple of folders, just to see how simple and straightforward it is.
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 »