Join Chaim Krause for an in-depth discussion in this video Important commands, part of SUSE Linux Enterprise Server Essential Training.
- [Instructor] There's a lot to know to administer a Linux server regardless of what (mumbles) is. You have to start somewhere though. And so what I've done is I've picked out a couple of the commands that we're gonna run at the command line in the shell environment. Sort of give you the tools you need to get started on the other commands. So I'm gonna through these and later I'll show you how to get more information about these commands so you can research them further. Right now, I've logged in on a terminal and I am user named User and I have the name of the box that I'm on, Linux-wnls and then a tilde.
The tilde means Home directory. Now how do we know where the Home directory is? For every user there is a directory created by the user name in the Home Directory. So the first thing I'm gonna start out with is a command PWD for Print Working Directory. And what it shows us is that we are indeed in Home user. And Home is where you keep all of your more personal files. Your documents. Anything that you're working on you're gonna keep there.
So let's see what we have in this directory and what I will use is the LS command for List and it's gonna list everything that's in that directory. So I see Bin, desktop, but what are these things? Types of files then. We looked at file types before, so if we do an ls-l we'll get the long listing here and it will tell us more about what each of those things are. Let's do some creation of our own. Let's create a file in that directory and there's a simple way to do that with a touch command.
You type Touch and then the name of the file, a file's gonna be created. We can see that by doing another listing. And My File is now here. If we want to put that in it's own director we have to make a directory to put it in. So the command we use is MKDIR for Make Directory and the name of the directory. We can see that's created by doing a list again. And now not only do we see My File, but we see My Directory.
Now what if we'd like to take My File and move it into My Directory? Well, there's an MV for Move and what you tell this, the file that you want to move and where you want to move it to. I'm gonna tell it that I want to move it into the My directory directory. So now if I do an LS, My File is gone. If I do an LS and provide the directory. So if I say, My Directory here, I will then see what is not in the current directory but what is in the directory that specified.
So we see My File is in My Directory. And to prove that I'm going to change directories. So CD for change directories into My Directory and now I'm gonna do a list. And there's My File. What if we don't want to move something but we want to copy it. So lets say I want to copy that file and leave it in it's original place as well. Let's make a new directory and we're gonna call that My Copy.
So there's our directory and now what I'm gonna use is the CP command. So I will say CP and then the file I want to copy. And then where I want to copy it to. I want to copy it to My Copy directory. Now I want it to have the same name. I'm just going to leave it blank with only the directory specified. So I'm gonna do a copy. I'm began type CP for Copy, then I'm gonna type the name of the file that I want to copy. Then I'm gonna type where I want to copy it to.
In this case, it's the My Copy directory. Now if I don't provide a name, it will use the same name as the file I'm copying from. So if we now do an ls, we see that we have My File here still and if we change to my copy and do an ls, we have My File as well. Now we've gone deep into our directory structure several times so once again, let's use that print working directory command we can see where we're at.
It says that we're in home, user, My Directory, my copy. So now I'm gonna show you some short cuts how to get around. If I do an ls-a for All all of a sudden we've got these extra listings here. One is a single dot and the other one is a double dot. If we do an ls, la to get both long and all we'll see them listed as directories. So what are those? Well, a single dot is your present directory.
So if you want to do something in your present directory you can specify that by using a dot and 2 dot means the parent directory. So if once again, if we print our working directory, we can see that we're in Home, User, My Directory, My Copy. So if I see The and then two dots, I'm began move to the parent so I'm began move to My Directory. The we can see that we're there by printing the working directory again. Now when we're done with our files we want to get rid of them so if I do a listing here to see what we have here, we've got My Copy directory, and we've got My File.
What I'd like to do is remove a file. So I use RM for remove and then the name of the file, that I want to remove. If we do a listing, that file is gone. Now what about that directory? I believe we've got something in there. We can show that by listing My Copy and yes, My File is in there. Couple things that are gonna happen if I try to remove my copy directory. First of all it's gonna tell us it's a directory.
Okay, no problem. Let's use remove dir for directory and do that command. Well now it's telling us that the directory is not empty. So how do we get rid of directory when there's files in it? Well if you are absolutely sure that you want to get rid of a directory and everything that's underneath, you can see an option and what I'm going to see here is I want to remove recursively -r, so it will dig down in there and follow it to the end and in this case remove everything.
So if I do that with a My Copy directory, now we do a listing. It's gone. So that's a little tricky when you've got files and you're trying to delete a directory. Just remember use recursively. Take note, what you if you put after the -r because if you put a directory like your home directory it will go ahead and remove everything home down. So you can see that's quite destructive.
So be careful with that. Couple of the commands I'd like to show you. Let's use clear. Clear is what clears the screen. You see me using that quite often. And then lets talk about files in the file contents. There is a command echo. If I use echo and then something, what it's going to do is it's going to echo that back to the screen. So it echoes Hello back to the screen. Now what I can do is I can take that echo and I can put that into file.
So let's echo hello and then I use the greater than sign. And I say, myfile.txt. It doesn't echo to the screen because it's being redirected into that file. So if we do an ls, there's our file. But how do we see what's in it? Well, there's a cat command which stands for catalog and that's an old term 'cause Linux has been around for quite some time but basically what it does, is it prints what's in the file.
So if I tell it to cat My File, I'm gonna see hello. That is the contents of that file. Now, lets look at some more larger files. I'm going to use our CD command to change to a different directory that got more files in it. Lets clear our screen and lets take a look at what's in this directory. We've got lots of files here and if you look one third of the way down the screen you see profile. html First off, lets see what kind of file that is.
So I will say, File Profile. Html and I will be told that it's an html document. So now lets look at that. So if I say Cat Profile. Html we'll, it fils up the screen. So how do I see what is previous to what's on the screen now? We'll, if you use the shift key and page up, you can scroll up. And you can use shift page down to scroll back down. There are some tool you can use to make this easier.
Now there is a program called More that you can see more of the file, but that one is a little old and there's a anywhere one called Less because less is more. So lets take a look at using less, with profile. html and what we get is we get lines one through ten out of 190. So this is approximately 10% of the file. Now we're in a program just like Notepad or Word to see the file but it's in Read Only Mode.
We can only see what's in the file, we can't change that. And how do we move around in here? Well, we need some help. So I'm gonna press the H key for help and what we'll get is a summary of the less commands. We get ones like Ford align, backward align, forward to window. Backward to window but the ones I want to you to see are U and D for up and down. So that's a good way to scroll up and down.
If we look at the line at the bottom here, it's as we press return for more or Q undone. So if I hit Return, we're going to get more of this file. It's gonna keep going until we get to the end or we can hit Q for done and we go back into our file. So now if I want to go down a screen, I hit my D key and I go down this half screen and I can go down, down, down, and then I can use the U key to go back up, up, up. So this is a good way to read the file and then when you're all done, you hit the Q key for Quit and you Exit less.
These are just some of the commands you'll use to get around. There's plenty more that you're gonna use on a regular basis, but these are the one you need to get started and we'll look at the other commands in some other videos.
- What is SUSE Linux Enterprise?
- Installing SLES
- Linux file types
- Working at the command line
- Managing processes
- Working with background processes
- Managing users and groups
- Changing file permissions
- Configuring network interfaces
- Displaying hardware information
- Managing drivers