Basics of Getting Help in Linux

Basics of Getting Help in Linux


This is just a quick video lecture to talk a little bit more about the “man” page and a couple of other ways that you can get help on a Unix system. So up to this point we’ve been using the man command to look at some command information. So if I do “man ls” it shows me what the ls command does. It shows me what options I can pass into the ls command. You’ll notice that this is actually using “less” the command we talked about in a previous lecture for paging.So, i can actually use the arrow keys to go up and down through this and read it. I can use the spacebar to jump down a page at a time and, notice, look at all the commands options that are available. I also want to point out in the man page it’ll often show you the single letter command option and kind of a longer more human readable option. Again, something we’ll talk about later but you know when you’re working on the command line you tend to use the shorter form because it’s quicker to type but if you’re writing scripts to automate processes the idea behind the really long version of the option name is that you can put it into a script and it is much more self commenting. So, it’s easier for someone reading your script to know what’s happening if you’re issuing commands from a script file. So, I scroll down through here it gives you some more information on what happens to tell you who wrote this file and any ways to report bugs. You’ll notice, you know, the copyright on these things and whatnot, so, and sometimes, you’ll also get different information or places that you can reference. So that’s the man page. One of the fun things to do is you can look at the man page for the man command and it will show you some secret powers of using the man command… man pages actually have multiple pages so you know that’s something that we can discuss later usually when you’re getting started out you only need the first man page for things, again, as we start to look deeper in the system we will talk about when and how you might need to reference different pages in a man file. Just good to know that man pages have multiple pages but for now we’re just going to look at the first page by issuing man and, by the way, you can do “man 1 ls” which will say go to the first page of the man page for ls. I don’t know, are their others? I have no idea. There’s no section two no section three…or so on so if a command ever tells you it has multiple sections and references a separate section of the man page then you can just enter that section name at the command line. Again, getting started we probably won’t run into that too often. There’s also a system on Unix called “info” I don’t use it. I’m pretty much used to the man page approach. I like reading man pages just because I’ve gotten used to it so what I would just demonstrate to you is that when you jump into the info screen it gives you the ability to kind of walk down and see a number of different programs that and the, kind of, the heading that they’re related to. So, if we look at like common options core utilities because if we remember looking back at ls it said “look at core utilities.” Basically I move that flashing cursor to the star of the item I’m interested in and what you’ll notice of the top two, it’s really important to read how to do this, “q” exits the info program “d” goes back a page. If you wanna look at help you can type “h”. So, I’m going to hit “enter” because I want to read about the core utilities. I’ve highlighted the core utilities. I hit “enter” I can now go down and look at a bunch of other things, right? Instead of doing video lectures I could just say, and sometimes I might just be like, “go read the info page on this command!” Let’s see if we can find something that looks good. Summarizing files…user interaction… file permissions we’ll talk about later… how about…Working context? Oh, there’s pwd let’s look at! So, 19…this is the section. It is all about working context. I’m gonna look at what pwd does and there it is! It’s a lot slowe, lot longer, way to get into information about a command. It’s much quicker to type “man pwd” Let’s go back out I’ll hit “d” then “d” Oops, “d” took me all the way up to the top so again, I don’t really use this but you might want to use info if you like that format and it gives you a little bit more of a useful presentation of that information. There’s also…let’s say, like, you forget something. There’s the command “apropos” I hope is installed on this machine so if I wanted to, don’t know, “apropos list” apropos being the french word for something appropriate, I think that’s what it translates to, will give me this really long list of things or commands that might be apropos to generating a list and I didn’t really give it a lot of good information but what you’ll see is that somewhere buried in there is the ls command. So that did actually give me a bunch of suggested commands that might solve my problem. You might find that apropos is helpful, or apropos, to solving some of your problems. Finally, in all these lectures I’ve been using the up arrow keys and down arrow keys to navigate through my shell history. What I want to do is demonstrate where these come from. So, I did “cd” which returns me to my home directory. I’m going to do an “ls -la” of all the files in my home directory and one of the things that we need to start looking at is this idea of configuration files. Remember we talked about this idea that there are certain files that are hidden in a directory if they start with the with a period. What I’m going to do is…this bash history file…every time I execute a command that command get saved into this file and what’s happening when I use the up and down arrow keys is that I’m actually just navigating that file. So now that we know how to use some of these commands let’s go ahead and let me do an ls -la Now i’m gonna do… is I’m going to do a “less” of everything in that bash history so I’ll type dot bash, notice when I hit tab it completes bash but it can’t go any further because there are three files that start with dot bash. So I’m going to give it a little help and do underbar “h” and hit tab and then hit enter and now what I’ve got is all of the commands that are stored in my bash history file from oldest to newest. It’s kind of cool to see those and you can see if I go back that it’s only one screen full so if you look at it it doesn’t seem that there’s a… I think maybe these don’t get cached out until I quit so let me see. Let’s see if those come back when i exit the terminal and go back in. There they are! So they don’t get cached out… your history doesn’t get written to that file until you actually quit the terminal and then all the items that were in your history at the time you quit. And, again it’s one of those things that once I did it I was like “oh that’s right it doesn’t write it right away!”