CompTIA Linux+ XK0-005 – Unit 04 – System Administration Part 3

  1. Command Aliases Part

Now, another command or optioning commands is called aliases. All right? You might have commands you have to type over and over and over again. In fact, let’s just say something as easy as the LS command. Maybe you always mean to include the long information with each of the LS commands. And you want to deal with color issues for the background. Whatever the case may be, instead of retyping it each and every time the exact same way. You can say, here’s an alias. And the alias could say, when I type LS, I really mean this long command. And there you go. It says, all right, that makes sense to me. I can now type LS, and I get this beautiful stuff that I want every single time. So the command to create those is simply just type in the command alias, put in the name of the command command that will represent the real command, the command syntax. And when you’re done, you’re done. You can just use it over and over again.

  1. Command Aliases Part

Now, I have seen some people do this in a variety of areas. For instance, if you’re used to working with vendor A routers and you have show commands that you like to run, and then you’re working with vendor B’s Firewalls and they’re using Get commands instead of show commands, then I see people create an alias that says if I type show, it really means Get because their habit was type show. So now they can go to both boxes and type literally the same commands and they feel good. It makes their life a lot easier. So that’s another way in which you might use aliases is if you had that kind of difference in operating system. So in this case, you don’t. So you may create aliases. Again, as I said have a short command that represents a very long set of command syntax just to make your life easier. Bye.

  1. Demo – Viewing and Creating Command Aliases

Well, now we’re going to do a little work with the alias command. And by the alias command, what we’re getting at is that we might not like the way a particular command works, or we want to create something brand new for us. And as an example, I’m going to use the witch option with LS. And you can see that LS actually is a command that is LS with the Colorado, the path to where LS is. Well, what I’m going to do is I’m actually going to actually create my own alias. I’m going to call my own alias list, and I’m going to say that my list command is in fact, let’s just make sure that when you use commands like list, that you are not using something that’s already in use. So maybe I need to do which K list for Ken’s list, and either one of those would have been just fine.

So let me clear that off. Oops ken typed my clear commands. So I’m going to go ahead and make my K list because I like that name better, and I’m going to alias this thing. Oops let’s alias first this K list and make it equal to in this case, we wanted the command LS, but we’re going to go ahead and add the L capital F feature there, and we’ll let the color be equal to auto, and we’ll hit enter. And just like that, hopefully, when I type K list, it does everything that I would have wanted it to do. So that was my way of making an alias set of commands that might be more customizable or easier for me to use than I would have had from any other option.

All right, so now that I have that part done, you could do that again over and over again. Like I said, there are a lot of people who might have decided that they have commands from other operating systems. Like Get might be a command that if they type it, they want it to actually do a show. Or some people come from the show world of Cisco. They might want show or SA to be a special command. And so you can do these things with your aliases to make the environment maybe more user friendly to what you’re used to.

  1. Environment Files

Now there are a number of different environmental files that you would use. Environment means that it’s about the configuration, about the user experience. So a lot of things like user profiles would be found under the etc. Which is a common directory for computer configuration stuff under profiles. The same with your shells you’ll have a Bash profile or a Bash login directory directory that you can deal with. Now remember these files, I’m not sure I said directories but I mean files, these files are often hidden. Hidden means that they’re actually preceded with a period so you wouldn’t see them unless you actually looked for the hidden attribute. Bash log out. All of these are just things that deal with how certain programs will run or what a user will see as they get logged in.

These are files you can change, you can edit and make more useful or change the functionality depending on what your needs are. So I guess what I’m saying is that you should be aware that these environment files exist and that you can alter them to give a different user experience whether if it’s just for you or if it’s for everyone that logs into the system. But again I’m going back to what I’ve said before with Linux is that it is very flexible for you to do whatever makes this system work best for you. In fact, between these and the aliases and some of the things I’ve talked about, the only downside you’re going to have in the future that I have run into is that you’ll have aliases for your favorite commands, you’ll have your own environment file set up just for you and then you go to this brand new Linux machine.

You type in your alias command that you’re used to it’s not there and you think something’s broken. You’re like oh what’s wrong? It’s not running right, it’s not installed right. Forgetting because you’ve gone for years with your aliases that this one doesn’t know your aliases or have your environment file set up the same way. So that’s about the only thing is you could get spoiled by what you give yourself as a benefit when you go to a different machine. So just remember go to a new machine. All that cool stuff you do not there, you have to redo it with each of those.

  1. Demo – Saving a Command Alias in an Environment File

Okay, we’re going to take a look at saving this command alias in our environment file so that it’s there all the time and not just at a oneshot deal. So I’m going to start off by looking at the Etsy profile, putting in the Moore command so we can see everything line by line. And what you’re going to see here is if I had any any other types of variables. I mean, I’ve got some path information. Again, it’s just different paths for different information. If I hit the space bar, it’s a pretty short little file even including like, what do I want the prompt to look like and all that sort of stuff. It’s written in a bit of a cryptic, if you would, type of scripting language. Something that if you really get into the scripting, you can start to figure out how they’re doing these things and have a lot of fun with them.

Anyway, that’s what’s in our system wide profile file, which is what we took a look at. So we’re going to CD to the home directory here and we should have already been there. Let’s do the PWD just to see where we’re at. We’re at Home Trainer and let’s take a look at the hidden files that are in our home directory. So we’re going to do an LSLA for finding that stuff that’s hidden in here and pipe it to the More command so we don’t get overwhelmed with all of these different files and everything with a dot, right? There is a hidden directory or a hidden file of some kind. All right, so now you’re going to see that we have quite a few different files. If we hit the space bar, you’ll see that even in my home directory I have a dot profile file. So that’s kind of the one that we’re going to play with.

We want to see what’s actually there. So we’re going to cat to our home directory the profile and see what’s there. And in our profile you’ll see that it looks a little bit like the one that we saw for the other setting. Again, a little if statement talks about the different Bash versions, the different path statements. Notice it’s important that with this user our path should be taking the path to our home location and to our bin directory. So it’s one of those things that helps us with default settings so that users have a consistency between their logins. Okay, we’re going to try to open up a different one now here with this next cat command, we also had the bashrc file. So I’m going to show that to you, bashrc. And that one I’m going to pipe to the Moore command because I expect it to be just a bit lengthier.

And this file is the one that’s going to be executed if you open a terminal window with the GUI. So that’s setting that up. Now remember, the pound signs are generally REM statements. So it says that this is going to be executed by Bash One for non login shells. And it tells us here to go to a different location to see examples of what’s happening. This little line here. Now, this is nice about good programming. You document your code. So this is saying if you’re not running interactively, don’t do anything. So you see the command that would put that in there. Don’t put duplicate lines in the history for bash one. Again, so history control.

And so again, all the way through here, you can see I’m going to go through quickly because I’m not going to read script to you today, but you can see that they talk about color support, aliases.And let’s back up. Let’s go up that one page and any aliases that we might have had with the LS command, at least I thought I might have seen one of those aliases show up as an example. Here we go. LS is set up already as LS Colorado, but it didn’t add in there the extra options of the L capital F. So I think we’re going to add that in there as well to our color with the existing aliases.

Okay, so I’m going to hit Q to quit through this. More command. There we go, to get us out of there. But you kind of get an idea of what’s been set up. And what I’m going to do is I’m going to use VI. In fact, I’m going to clear my screen. I’m going to use VI to edit the RC file, and I’m going to page down as much as I need to get to the end of this file. I got down to the end of the very last. In fact, it’s kind of sad I didn’t give you a chance to actually see the rest of that code. Notice I tried to use my mouse on the sidebar, but there is no such creature here. Bi goes back to the 70s where there were no scroll bars. So page down all the way. End key takes me to the end character, gets me out there. And then I’m going to type in a for append.

I’m going to now put in a new line with my Enter key. And we’re going to type in here. Oops alias is going to be LS equals single quote, the LS with the L capital F option space, the dash color equal auto. So we still want to keep that color option in there and then the end of that. Now here you’re used to me probably typing Enter because we’re so used to these programs like Writer and all of these other things that we use. And in reality, I’m done editing. I don’t need a new line return. So I’m going to press escape to get out of the editing mode. I’m now in command mode, and commands start with a colon. So when I hit the colon. If you look at the bottom of this screen, you can see where the colon shows up. WQ for right? And quit. Enter. And now what we’re going to do is we’re going to cat that Bash file again, and we’ll just go to the end.

And at the very end, you can see now the alias command that I’ve put in there. Okay? So that is my new setting that I have. I’m going to close the terminal window and open a new one. In a way, I’m kind of doing a reboot of my terminal session. So as I build it open, right as I open up a new one, it’s rereading this Bash file. So the last one that I had open, even though I made changes, it wasn’t there. I’m going to type LS, and you can see that it’s adding the color and the dash LF option, as I would normally have done for the alias. So I’ve set it in there, and we did the editing. We did it through VI. There are, I’m sure, many other ways you can open up a text file, but VI seems to be still one of those things popular today. Maybe not as much as it was in the, but it’s still out there. All right, so that was editing the aliases

  1. Topic D: GUI Configuration

All right. Now, the next thing we’re going to do is talk about the GUI configuration. I know you some of you are finally saying, oh, finally. No more of that shell stuff. Well, okay, don’t get too excited. We’re just going to talk about how to configure the GUI again, to customize it, to make it work for you.

  1. Video Configuration

Alright? So if you start the installation, you’re going to see that the installer normally configures the GUI settings for you. And with most of them it starts automatically after the thing is installed. Now that’s not necessarily true with every version. In many cases, every time you start up a Linux box, some versions may have you log in and just leave leave you at a command prompt, meaning that you would have to type something like Start X to start the GUI portion. So most of the time it comes on today, but you might have some older versions or some super user or experienced user versions where if you want it, you put it in there. Now, depending again on whether it’s a new version of the Linux operating system, if it’s an older one, you may have to do your own manual configuration. There’s two types of configurations you have the original X Eleven standards or the X 386 standards. Those configuration files are found under the Etsy directory. Now, if you make these changes to these files, these configuration files, you make them manually.

You do have to provide the information about your video hardware. That would be the frequency for refreshing the screen resolutions, the color capabilities those things that we normally used to have to do manually in the old days. I like to say old days because I’m only talking like five to ten years ago. That’s really not that long ago. But again, things have improved. Technology has made it a lot easier for us and it’s kind of like everybody coming in brand new doesn’t remember how difficult we used to have it. It’s like those stories about having to walk to school through the snow uphill both directions. That’s what it was like for us. It’s easier today. But you need to know what those details are if you’re going to manually make the changes.

  1. Screen Resolution

Now, if you use as an example the desktop environment of Gnome, you’ll see that you have a video capability through the GUI to change whatever you need to change. So if you want, you can open up a Gui to change things like the screen resolution. Well, this is a normal Windows user experience where they can right click on the desktop and go to the environment and make the change. That’s what we’re doing here. Change the refresh rates. You can change the resolutions. You can even change the rotation depending on the capabilities of the device itself. Now, you have also the choice to say that this is going to be default for the entire computer. Or maybe it’s just something you like. Now, some of you really love what I call micro print resolution. That’s great. Don’t make that for us who are bit older, whose eyes aren’t as strong. Your choice if it’s default for everybody or just for you. So you can make those changes. But that’s nice that you have those capabilities.

img