CompTIA Linux+ XK0-005 – Unit 15 – Troubleshooting and Maintenance part 3

  1. Obtaining Files

Now, there are other ways that you can go about grabbing files in case you don’t have an FTP server. And those commands would be things like Wget, which is a command that was designed to help you download files through either http https or FTP again, often trying to download a patch or a fix or an update or something that you need on your system to help you with the repair or the troubleshooting. You can also used the command curl curl to do the same thing. But the nice thing about curl was it was designed to be a scriptable command, so you can put it into a script and download things automatically.

  1. File Verification

Now, once you get these files, one of the things you should do is verify that it is the right file. Especially if you’re worried about somebody infecting you with something that’s going to cause problems. There are many things we can do to do a file verification and we often talk about comparing its signatures. But in our world that’s hashing. Hashing is a method of doing a mathematical transformation of a file of any size, any length, and it comes out with a fixed numerical sum. Now what it means by fixes I mean a fixed length. So whether your file contains one character or millions of characters, when it’s done, the resulting hash will be of a certain size. Now, if that file changes by one little bit, that means a bit that was a zero becomes a one or a one becomes a zero, or somebody takes a bit away or adds an extra bit.

The resultant hash was designed to be so different that you can detect the differences without having to analyze that 128 or 140 or 160 bit result. The effect a change occurs so drastically is called the waterfall effect. We want to know that one little change here is going to cascade down and just change everything else and make a completely new value.Now these hashing techniques are designed to be a one way process. That means that if I know a hash of something, there’s no way I can turn it back to the original. I mean, if I had a 5 million character file and I’ve got 128 bit resulting hash, there’s no way I can turn that back into 5 million bits.

Now, there are many commands that you can use to run the hashing process. The two most common hashes that we accept today is Message Digest Five and the Secure Hash algorithm version one, Shaw One. The commands you would run to get the hash of the file. So you can compare it with the hash that was provided to you as being legitimate. It would be the MD five sum command or the sha one command. Now you can also use this little utility called the Ghanu Privacy Guard or the GNU PG, and that we’ll allow you to check the public key of a publisher and verify that the publisher of some software or some program is indeed the one that they say they are. That’s also important that you say that. I want to trust the person that’s sending to me as well. 

  1. Topic C: Scripting Basics

Well, now we’re going to talk about scripting basics. And again, the idea of scripts is that you’re going to create some sort of code, some sort of series of steps and commands that you probably have intentions of being rerun over and over again, be they startup scripts or daily tasks or whatever else you want it to be.

  1. Scripting

Now, when we talk about scripting, we’re simply going to create a text file using some sort of text editor. Maybe my favorite VI. On the very first line, though, you have to add what’s called a shebang. Some people call it a magic number. It is actually a combination of the pound sign or octothorp, followed by the exclamation point, then followed by the path to the actual command shell or bash shell that you’re going to use to run this series of scripts. From there, you’re going to add whatever series of commands you want to have executed, and when you’re done, you save it. Then, using the change mod command, mark the file as executable. That’s the change mod with a dash x and then whatever name of that file is so everybody knows it’s an executable file, not just some sort of text file.

  1. A Script

Now when you look at some examples of a script, it’s pretty straightforward stuff. So we can take a look at the example here and we see Shebang bin Bash is where the shell is. Then you got a bunch of pound signs which are just remarks so it’s not actual commands. And then you have a series of things like echo. Now echo is a way of saying basically print this out to the screen so it would say calculate in square. Then you have an echo e that says enter a number followed by a slash C. Now here’s the thing about that. The slash C is saying don’t go and create a new line because obviously you probably want them to type the number next to the actual words that say enter a number.

Then they’re going to ask you to read whatever you typed in. They’re going to store it in a value or a variable called number. So the command read says read that number. Then you’re going to declare a new variable. Now the variables you create are going to have to be typed whether they’re supposed to be integers or real numbers or whatever it is. So we see in our example they’re going to declare as a type I integer a variable called square. And then they say that square is going to equal basically that number multiplied by itself. From there they’re going to say, well now here is the actual square of the number they echo to the screen. The square of they use that reference.

Remember the dollar sign is saying that this is a variable and so they’re going to say the number is and then whatever the answer is and you’re done. It’s a very simple little program to just kind of explain to you how you can write something cool stuff, maybe your own games if you want, maybe a celsius to fahrenheit converter or maybe you actually want to have it read your mail or do something else. But it’s just a simple way of showing you ways that you can create scripts that are programs that run over and over again and can be interactive.

  1. Commands

So let’s talk about some of those example commands you saw on the script. Remember that all scripts start with the shebang, the pound, octathorpe, hash, whatever you want to call it, and the exclamation point with the path to the shell, the bash shell echo was repeated to the screen, the pound signed all by itself. That was the comments echo with the E followed by a slash n mint new line C meant don’t go to a new line. The slash C just simply said that echo whatever this is going to be, but don’t start going to a new line because often, like I said, you might want the user to enter some data and not have the confusion of suddenly seeing what they type be at the end or on a new line of the question.

You want it to be right there. Now, when you are asking for this interaction, you’re asking for this information in, you need a read command that says basically read the input from the user, store it in whatever variable you create. Also, we said that if you are going to create variables of certain types, especially numeric values, use the declare command, put in the type of variable that’s going to be and then the name of the variable. And that’s just some of the that isn’t even scratching the surface of what you can do with your scripting commands, but it’s a way at least of encouraging you, I hope, to start looking at what other cool stuff you can do with scripts.

  1. Demo – Writing and Testing a Shell Script

All right, we’re going to create our own little script. And to do that, I’m going to open up the text editor g edit and we’re going to create a brand new script. We’re going to start off with our shebang, as of course we know we need. And I’m going to put in the path to the bash shell. From there I’m going to put in another pound sign and another pound sign or octathorpe or hash. And again, just remember this is a remark statement and this thing is going to calculate the square of a user supplied number and that bit of the calculations. Then we’re going to echo some stuff out to the screen so the user gets an idea of what they’re supposed to do. So this will say calculate a square. The bad side about this is if I screw up on the typing, you’ll all be able to see it right away.

And I never think that’s fair that everybody gets to see what I do anyway. So now we’re going to wait for them to enter a number. And so we’ll echo the request to them to enter a number. And then I’ll put a colon after it and slash C. And from there we’re going to read the value and we’re going to put it into our little variable called number. Now we’re going to declare a new variable. This is going to be a type integer. We’re going to call it a square and we’re going to say that the variable square is going to be equal to in this case, it’s going to be equal to the value number. Of course, the multiply is the asterisk times the number. Now remember, we’re using the dollar signs to indicate that these are variables.

Now that we know what square is, we’re going to echo back to the screen for the user that the can’t spell the square of what they typed in number is. And of course, it’s going to be the new variable that we did square. All right? So put that end quote on there. And if you’re not quite sure, why did I put a number sign or dollar sign here and not put one over here? Well, the dollar sign here is so the actual value of the variable gets printed in the screen. This is not being printed through echo, so it’s just the declaration of what they’ve done. So you kind of get the idea, I suppose, as you’re going through and doing this.

All right. So now I’ve got this script and hopefully I haven’t done any typos. And what I’m thinking I’m doing is going to work. I’m going to save this as a file called square script. And I’ve got it in my Trainer folder. Good. So it’s in my home directory. All right? So now that I’ve got that done, I’m going to close down this text editor. I’m going to do a quick LS so I can see square script is in there. In fact, if I do the LS LF, you’ll see that it is not listed as an executable program. So I’m going to change the mode of this to add the execute to it to square script. Now let’s do that same LS command again. Now you can see that it has become an executable program, which is important because without that, it would never be run, it would just be our text file.

So now I’m going to do a with the path to the square script and otherwise it’s not going to be able to find the script. I’m going to hit Enter and it says, okay, enter a number. So I’m going to put in the number seven. Seven. And I hope that I get the answer. 49. And there, just like that, I quickly ran my new little script. So making scripts, things that you can schedule, things you can do whatever you want to with, is quite convenient, very easy to do in the Linux operating system. And that was a quick example of just using a simple text file, marking it as executable and saying, run this script.

  1. Unit 15 Review

So in this unit, we talked a lot about the troubleshooting processes for the system and for the networking. And we looked at the boot process, changing run levels, even how to recover that root password, should you need to be able to get into a system where that’s either been lost or whatever the case may be. Once that system is up, it’s running. And don’t forget, even if you had to, to do a recovery with the recovery disk, once that was is done, if you’re still having issues with connectivity, well, that moved us to the networks. And we talked about how to troubleshoot the network connectivity.

Some commands you can use to verify that your configurations are correct, some hints about what different parts of the network you should be interested in, how different commands like ping or trace route might be able to help you. And then finally, we talked about some things you could do to create scripts that might be able to help you with doing all of these things I talked about. Now, even though we gave you an example of a cool little game of how to square numbers in your scripts, the idea is that you can write and test your shell scripts and those scripts could include the commands like ping and trace route and some of these other things that we’ve talked about.

And you might find them to be very helpful in being able to do some automatic troubleshooting, especially in the network world. So our goal was to make sure that you had more tools and more capabilities in trying to figure out what’s wrong should there ever be a problem and a process to go through, to be able to at least if anything, if you couldn’t fix it, be able to know where to look or who to contact to come up with the solutions to get everything working again.

  1. Course Closure

Well so here we are at the end of our course talking about Linux. Now, I hope you got a lot out of it probably were surprised at all of the different areas and topics that we covered. Now, a lot of you who come from the Windows environment are probably saying wow, this Linux is doing what I was doing in Windows but I hope you got a little more out of that. I hope you saw that there was a lot of cool flexibility a lot of great features and utilities and things that are free with Linux that give you some of the same functionality if maybe not more or different functionality. Now, I also try to make sure that I played a good politician by not saying Linux is better than Windows or Windows is better than Mac or any of those things because that’s not what’s important to me.

What’s important to me is you understand the features and capabilities of the operating system so you can decide how best to use it to meet your business needs. In fact, that’s always been my focus is what’s going to make your business succeed? Remember, often in the It world we’re trying to support the business, make it profitable so we keep working. We want to just know what are the tools and that’s what we did with Linux. Now. We started off by talking about the installation of Linux talking about the different distros, talking about some of the checklists or pre installation tasks you need to go through. And we talked about some of the typical Linux installations.

We then move straight into the ways in which you’re going to be working with Linux both through a graphical user interface or through the command line. From there we try to make sense out of the file directory management to understand the directory organization and to talk about this file hierarchical structure. The FHS that you needed to know about. We talked about file management how you can manually create files through the command line using applications all of the things that are important to us moving them, copying them, renaming them we even dealt with how to add in removable storage like USBs, CDs, DVDs and what that does to the overall effect of the file system. From there we moved to system administration.

We talked about creating users and groups assigning permissions to the files and directories to these different users and groups and even how to work with the users environment in the user configurations and creating the environmental variables such as the default settings for their home directories and everything else. And then we talked about how to configure the GUI backgrounds, the GUI options, your screen resolutions and screen savers and those things. From there we moved to the one part of Linux that scares a lot of people, which is application management. Now, the first part wasn’t scary at all it was how to install a package software package that you download or purchase or whatever, install the media, just run a regular setup and you’re done.

But then we hit the part that does scare people, and that is starting off with a source code text file and actually being able to compile it and getting it to run on your system. From there, we moved into your system configuration. We talked about your disk management, what really is happening with a hard drive, talked about the different file systems that you can use on the different types of disks, whether USB or hard drives, large hard drives, CDs, DVDs and the likes. We then even talked about other types of devices that you were going to manage and what does it take to actually work with the device through Linux. Then we talked about some ways of fine tuning through the process and module management.

We talked about the processes, the Budapest, the process IDs, the parentchild relationships, how to kill the process, change its priority and execution. And then we worked with kernel modules and talked about things that we can do to try to again help fine tune the way things run. From there, we talked about maintenance issues, especially for recover abilities like backup and restore. Had to schedule tasks either one time only or through cron jobs. Talked about performance monitoring, looking at and storing log information about what’s happening. Then we finally moved outside of the Linux box and got into networking.

And we talked about the basics of networking, the types of network services that are out there, specifically talking about domain name services because that’s a very important part about most of our navigation. We then continue to stay outside the box, talking about file sharing and printing, both connecting to a file share or having people connect to us through the network file resources. We also talked about printing. We then got into some of the options you have with Interoperability, such as this idea of Samba to be able to actually offer a Windows like connectivity. Also about the remote desktop capabilities and other things that we could try to make Linux and Windows work together as one big happy family.

From there, we get on to system security. Talking about what really is going on with the system. Talking about issues with passwords and password files, network security, locking things down, dealing with different ports and some options that you can use to make your system safer out there in the environment. Including things like using it as a router, using it as a firewall, using the intrusion detection capabilities and all those things that add layers of protection. We then talked about the web environment where we talked about the Apache web services, talked about the MySQL servers running in the back end to fuel the information that your web pages are going to deliver.

We talked about your FTP and email services. So you understood what’s going on with FTP, what it took to be a client or the server. And we talked about the different client services you have as working with mail servers. And then finally we left you with troubleshooting and maintenance to make sure. We talked about all aspects of booting up Linux, the process that goes through password recovery, moving from there to troubleshooting network capabilities, and even putting in a lot of the functionality by creating scripts that can run and do these checks for you or help you with your analysis. It was a lot of information, like I said about Linux.

I hope you feel very comfortable with this as an operating system. And it’s no longer this scary thing that you hear about hackers only working with it in fact, you didn’t hear me talk about this being the hacking tool environment. I’m talking about it being a serious server enterprise benefit for your corporation or even as a workstation for you to be able to use. Granted, all of these cool tools that run on Linux do provide the great platform for running hacking services or running penetration testing but that’s not the emphasis here linux is a legitimate tool that can work very very well inside of your business.

 

 

img