Welcome to Cyberia. T. I'm Greg Stewart on your subject matter expert for Lennox. Plus.
So this is module three, part three, creating files and directories. This is a great module. This is Ah, there's a lot of good information that's in this module. Salud. Without further ado, let's get into it. Let's start creating files and understand how to create directories. Also,
we're gonna touch a little bit how to move things around to wave, have touched on it a little bit before. But we're gonna go a little on death on it in this module.
be my work station box. I'm gonna blow it up,
okay? And I'm going to clear
is me clear screen. All right, So what's a quipped way that we can create a text file? We're talking about strictly using the command line. Right? Because I know that if I
go to my desktop, I right click Aiken, do a new document.
New empty document. Done. Documents been created. That's pretty simple.
But the reason we're using the command line again is because if we as systems administrators need to remotely log into somebody's machine and don't have any Cooley access. We're gonna be using SS H to determine a window.
So in order to you know, in that case, we're gonna be wanting to know how to do things. Be the command line. Don't stress it
so much in this class that, if anything, I want you to come away from this course.
Don't necessarily care so much about you being, you know, passing the test on the first shot or scoring super high.
Come away from this course, having a better understanding of the command, why it's so important. And I t. As a whole
you use command line so much in Mac OS X devices or UNIX or
Lennox devices even, you know, take some time and study some of the command line stuff for Windows. There's a few similarities things air named differently and displayed little bit differently about becoming an expert at the command line can really propel your career beyond systems administrator. You could become seniors too sad man, a system engineer
and eventually an architect. So there's a lot that you can do with the command line, and feeling comfortable and confident with it, especially around clients, is great because you build confidence. They build their confidence in us, A systems administrator, and they'll come to you. And
I feel like you're the subject matter expert. And that's the idea of what we want to do with this course. So please learn the command line, get good at it.
The beautiful thing about it is these linens boxes air free. You can download in stone wherever you want and then just play with all day long. So
command lines agreed. Tool. So we're gonna create files and directories using the command line. Let's start off by creating a file to show you
I'm gonna demonstrate two different ways that you can create a file. Okay.
Well, just actually create the file
as a container, Okay? It's going to create a file, and it's gonna give it a name. And that command is actually called me. Touch Command is touch, So I'm gonna touch.
I'm actually in the log, Director Emily, back out. I'm gonna go back to my home.
Okay? If I do a CD with a little squiggly right there and drops it back in my home, so do P W d in a root,
CD home Sy Berry admin
and Pierre the D. M. Back in my home directory and was staying in my home directory to do these,
do these things. I'm gonna move between my home directory and actually the desktop under my home directory just so you can get an idea of how things move around.
and let's call the file,
what can we call it? Fellas? Just call a test for now.
Done. Okay, so that document test it exists now. So let's see where that where it is gonna do in L s.
And you could see that Barry's right there. Test. Okay, I can craze much. Don't want touch test too.
Doing less. And there's a document again here. Test too. Right.
Um, if I don't like, uh, you know, if I don't like the name that you could name whatever I'm just using test is as a test is an example. You can create whatever doctor you want. If you want to do a test, huh?
fantasy football tracker.
I'm sorry I wrote that. I did the wrong Santa wrong command. So that you touch
on list. And there is France football tracker. Okay.
And so that's That's the touch command. That's a way of doing it. Now, what I would do if I If I want to edit that, we're gonna get into filing And in the next part of this module,
well, you could do the eye fantasy football into ah,
auto complete biting the tab key and drops you into the V I editor. Now there's nothing in this file currently because you have it. It's just a blank, empty file. It's a container
liken type. By hitting the I commit, I button lower case, I puts me in the importance of input mode.
My draft order will be
on. Do you know what Gronkowski is? My tight end. That's me. My first draft pick this year. I picked Adrian Peterson. It was huge mistaking that missing the entire season with litigation.
Um, maybe I want to have manning if he makes it back
on. Then I wanna draft you always look for drafting a good defense, so I'm gonna pick Seattle
s. So that's gonna build my draft order. It doesn't matter of adult what you put the dog community, Doc, Man, I'm gonna hit the escape key
That takes me out of editing mode. And then they hit Ah, Coghlan. Coghlan kills the session of editing and now it's gonna ask me. It gives me a chance. Prompt me what I want to do for this point.
I could do it. Quit If I just do quit,
it's actually just going to quit and not save anything I wanna do, Right, Quit or a W. Q.
That's going to save the changes to that file.
So now that I actually have something written in my fantasy, football owners were tracker file I can use the cat man
shows me the output of what's in my file, right?
Shows me that my draft early on, Cassie Manning and in Seattle Okay,
do that with any You can do that thing any of the files that you created. Using a touch command touches a great tool, especially if you just want to test and test permissions. Kay.
um, now that we've done that,
let's do it. Let's use another command, OK? The other command
theater command is going to be
the cat command, actually itself okay, with the cat command. We can use CAT to actually create the file. And Ben add text in the file
on same command with with an actual arguments, the greater that arguments listed cat.
Okay. And then we'll do a greater van
and let's let's create another one. Just to a sample.
Probably. We have sampled on Texans who stands to sample
Okay. What? That stuff is automatically he's dropped me into this
kind of ah, pseudo file editor. Right? So you can see my cursor there is flashing. It's Give me a chance to input anything. I want to do it. So now anything I type is gonna go into this file. Okay? So I'm gonna type. This is a test file.
Okay. When it hit, enter that. I'm gonna get control. D and I'm out and I've saved control. D is going to save it, kill the editing and save the file. Okay,
so now sample file. Where is that show up? Or did it right in getting places to in l s
Okay. And there it is right there. Sample filed out text. Okay.
Now, if I won't actually see the output of that file again, I could use the same command cat and then just sample file.
And there you see, There it is. The test file. Love Ellis. Commanding makes so easy to actually create a final edit all of the books.
So that's you can do this with this. This command his cat command
to create files. And you can also do the touch command. Great way to quickly just create a text file,
get knocked out and have it ready to go so you can take notes or do whatever you need to do. This is just a quick way of creating files.
We've seen how you can create a just a simple text file by going to the document, but going to the desktop and creating it
and you got to go now. We talked a little bit about moving things around. If I want to move this file
from, you know, Stan, wanna move sample file
context and I want to move it to the route.
The same woman move into roots. Don't do this. And
it's actually for class.
Okay, so let me go to root.
Actually, I was gonna list through, so if I do l s route
their sample filed out texts.
Okay, well, what if I want to have a copying each in each directory? I can do that to raising the CPQ man from a C P. Sample file.
Actually, now, I can't do it in here anymore in this direction because I moved it to the
route direct. So I'm gonna go see these root, and I'm gonna do a move
sample file out of complete
and Bank. Put it there.
Okay, now that it's there, I could have done it. Either way, I'm gonna go back into that, So I'm gonna go toc home cyber ery and men.
Yeah. Copy. This time, a copy. The file sample file.
And I'm also you can do multiple possible copy test and test two. And I'm just sitting these two
the IV route. I've just made a copy of those three files in one command and move those copies over to the Russo. Let's do it l s of at and there you can see all my files, sample file a text test and test too.
Great tool to move things around. Could command to move things around copy items.
And that's a great way to actually go ahead and do that. Okay.
Okay, so we've done that. We know how to create a file.
We know how to move a file around.
What about the permissions on the file? Okay. How do you know Who can read and write execute who owns it
and how you have how that even is displayed in lyrics slightly. It'll be easier and windows because you could go the graphical interface, and you can see
that it has be in all the different you go to security tab. You could see used the owner of the file and everything reach out, contact that owner. You know, it's it's a little bit different window. So in this situation, I'm going to say that is actually slightly more difficult and complicated
in a linen file system trying to understand
the directory, trying not the director, but the permission of a file is slightly more difficult than it is on windows.
So let's take a look at what Thea almost killed this.
Let's take a look at what the actual permissions look like in a lyrics file. And for for this example, we're gonna use our sample filed out text.
So I want to do in L s
Bash Fell, which is going to show list me of the permissions off a file that I'm going to specify.
What you're seeing here is what it's telling me right now it's telling me that it's
You're r w free right are
couple dashes are and a one. But what does that really tell me? I mean, looking at that, that doesn't really give you
and he doesn't give you a lot. Really? So let's let's let's break down. What? Each of those
What each of those items actually mean. Okay, so
you know, with the permissions in the command line
Well, you know what? You're looking at us. The user rights and permissions First character
starts with. If you look at, it starts with a dash. Okay. The dash, This is ah, special permissions. Flag this Berries.
The falling set of three characters are the r w in our arses are W than a dash. Okay,
is for the owner permissions. So it's basically broken up in three. Second set of three is for group permissions, and 1/3 set of three is for all user permissions. Okay, so you can see there are down here. Let's clear this so we can bring up top.
That was due that same command again.
123123123 Okay, so this 1st 1 here
then the rest of them going, going forward are permissions. So first
is going to be the owners permissions which I'm the creator. I'm the owner of this. I have rewriting permissions, read and write permissions.
The 2nd 3 set of three characters is for the group commissions.
Currently, any groups that have access to this can only read It's really for them.
And the third set of three is going to actually be all the rest of the user group permissions.
And so what we're doing is trying to figure out how to create the permissions for this so it's a little bit easier. Okay,
the permission groups used Are you for owner
O R. A for all users. Okay.
And so what we want to do is the r stands for Reed, the W stand for right in the X stands for execute.
So in our file here, it means that the owner has read and write. The group only has read and all users have read.
so what if I don't want
once I'm the only one that I'm alone. I'm the only one that wants to be able to have access for reading, right? Or any permission for that? For aspect to this file,
I can use a command which is generally pronounces Jamaat. What it is is actually changing,
changing, changing them or modifying Jamaat. Okay, I'm gonna change. The permissions
I'm doing is changing the ownership permissions on this A mammoth, honest admission. But the file permissions on this specific file Okay, so you want to actually type the command
if you look at, let's back up for a second, because we have to figure out how this is just calculated.
I'm gonna pull up a text file for this will be easy for you to understand. If I write it out
you get back to my desktop
and student. This untitled document here,
Trying to stay away from slides don't actually have slides for this. So I want to make it so you don't have to have your power point by death or anything. So let's look at the three ownership stuff. So, for an arm,
actually, it's a little case Are
that actually equals four?
So what you're doing is you're gonna add the numbers together to get the number representing the permissions you wish to say.
We'll need to include all the binary permissions for each of the three permission groups you got. Including all three permission groups. Okay,
Sonar example. We had a dash,
and then we had an r w
dash are bash, dash and our bash dash, and it stays in. This stays in this format. Read, right. Execute, Read. Right. Execute, read. Right. Execute. You see it like this pretty much every time. It doesn't change.
So first to send a filed with Recep file permissions to read, rewrite, execute, read You have to change our ahmad Filed 277 44 file for a while.
So let's say we want to
on Lee have Let's just say we want to blow up quite open. We want everybody to have full access for you. Don't execute for everything.
What do you think the answer would be for our command? For tomato man, We're just going to pretend like this. Is that right of command Prompt here, ma,
um and then you're going to want to type in the
great the file. Okay, So to go back to our
must take him out of full screen so we could see both the text file and are
So let's do, uh, ma,
and I'll stand and let's change it. So what do we need to do if we want to make everybody you So you have to do is you have to add up these numbers
to create the image of that we want to use for each of the permission times.
Right. So we're gonna type in what we need is ah,
And you need something for
We need to be able to know each of these What they're going to be what they add up to right, because right now it adds up to what?
What we're currently looking at for our permissions and the numerical presentation is ours. Force. That's four
and the double used to. So it's a six. So we're looking at a six.
I'm sorry about six and a
two and a too. Right.
So this 1st 1 this is our owner permissions on second represents two. This is our
I'm sorry I wrote this role.
Let's back out. This is going to be a
read and write, which is a six
read which is a four and read, which is a four.
So this is gonna be 644
is going to be reading, right? So that's six vehicles up to six here. In our little calculation,
this next set equals 24 There's only one car and then following said is also for so for
group Russians and for all users permission. They both only have read access. So it's a 644 I want to change the change at lunch monitors Something where everybody can do everything. Read, write an excuse. What would that be?
Take a second. Think about it.
Grabbed. Bring the water.
hopefully you've figured it out. It's fairly simple. You're gonna make it just 777
Because, Reid, right, execute equal to seven. And for the owners, the owners,
the group and all other users, they all are gonna have rewriting. Excuse with 777 Let's give it a shot and see the changes at all.
So back in my command, do 777 and sample filed up. Text enter
and now is doing l s minus l sample
And what does it look like?
It is different now. You can see that the command line is now.
I'm sorry. Not the command line. The permission set.
What is it now? The commission set. Now it looks like this.
You still see we have a first variable there. That changes. But then we had better be ex part of the pack. Start of you are the big tax. Okay, so now everybody
that kid's had see this file in their system has full access to rewrite and execute.
So these air file commissions and changes for everything you can change to whatever you want to be?
Let's try a different one changes so that
only the owner has read. Right? Next. Cute. We're gonna change to the seven everybody else on Lee has read. Only has ah
We did that one. That's 644 So let's do read. And everybody else has just read. Right?
So 12766 and sample files on text.
And you're Ellis my spell sample
next, and you see that has changed. Now reads our daily X r w dash r w dash hope they understanding this this point time is slightly confusing. And it could get extra confusing if I type a. This is where it gets a little crazy. If I type in L s Dash L A
is gonna tell me all the permissions of every file in that directory.
all the different ones. Let me expand this little bit sitting. See back. There we go.
You can see that each one has its own
And what do you think? The ones with the d. R. In front of it,
you can actually change the permissions on directories. Okay.
So you can see here the directory of route the owner has rewrite. Execute the group's only have read right?
I only have read and execute and all the permissions will read and execute all of the group. Other members groups.
So then it's difference of cyber answer my history.
I am. You can see here just a seven.
So you can see here is just seven and there's no others, right? So I only have or six I'm sorry. I only have read right access to my history, my shell history,
these directories of the D in front of it. It changes, right? So
you can see now. And I hope I've broken it down easy enough for you to understand what it's like, how it's broken down, permission wise.
So now you know how to change permissions.
You know how to create a file and changed the permissions on that file both extremely important things to understand. This is a ministry Er OK, so that special commissions flag we talked about can be any of the following things. It could be a D for directory
D for directory. Lower case.
The filer directories is symbolically, it could be an s.
This is going to be the set. You a year set G I t permissions. This is for those things, and a T indicates it's sticky bit permissions. This this is not this set is not displayed in the special permissions. Part of the permissions display was represented as a team. The execute cute of abortion, of all the user permissions.
these things, the most common ones, you're going to see your just d or just a straight up dash
for us. Just a file, Okay?
And you can see that my files
are there. Other areas are just with a dash. Was the most common ones you're gonna deal with and you're gonna see on a regular basis. So now you know how to create files. Let's talk about directories.
Directories are pretty much just as simple as
as files. Okay, so what we're gonna do for,
um, we're gonna do for directories is we want to make a directory. We can do that. We can do whatever he wants. The beautiful thing of
So let's go, Thio. Possible to go when we can do our own maker. The command is going to be maker.
so let's go back to work mail. I'm gonna clear this out again. A clear man.
And within my home directory, I'm gonna do a maker, and I'm gonna call it scripts.
Okay? This is a common directory to wanna have. You can put all of your own scripts that you write in the script, Fuller than you could call it up when you're on your scripts. So let's do it. L s.
And you can see now that I have a directory named scripts, you can see the difference. And why should done really? Is done it with a capsule x er
So our end urges to remove scripts. And what we didn't cover Rosa was the are in
are in command, just removes. Okay,
so I'm gonna show you something. A very powerful command here in a second That will blow your mind.
It could be very dangerous if you do it in the wrong directory, but we'll get to that in a second. Let me jump back a second to go back to the file Curry creation.
We create files by doing that. You know, we thought about touching the cat command by doing our m, it removes the file together. It will delete it. Okay, so it's a good command you can use
back to directory. So student makers just in Cady are, and let's do it. Scripts. And generally directories are capitalized.
Just the first letter, and you can see the difference in directories. And it's actually bloom. Stabbed just white. White is just files. Just text text file stuff.
So good stuff. Now you know how to make a directory. It's easy,
um, to remove a directory. Just Azizi. And, like, we just did remove rnd I our scripts.
Okay, now it's gone.
I'm just gonna go back and dio
maker and back scripts. Okay,
so now we have a directory called scripts. So what's
Let's go into that director, You're gonna see the into scripts
now again. So to CTU have to change the director again. A scripts, text, scripts, takes you there. We'll do l s
nothing. Right. But what do L s s a
shows. May have did and did it. Those are my directory. Navigational points. So we doing? L s minus l. A
shows me those Those two points where it takes me. Okay.
Did it will take me back one level
and just a day it will take you back to route. Okay, So you changed drugs you can do that. Sells you the permissions for it.
So that would create our director. Let's put some files in there, OK? And I'm actually what I'm gonna do is just gonna go back,
and I'm going to move
file, and I'm gonna move those. Let's copy them, Actually do C p test
too, Because whenever we remove test, and I'm going to do a
and then copy sample file
And do you fancy football?
Yeah. And copy those over to
Okay, Now, I have some files in my newly created directory,
which is a good thing You don't want bling directors floating around. Okay, so I've got files in there.
I'm done with this. I don't want any of the files that are left
you know, or let's say I want to actually change ownership
of every file. It's in here ownership, but I want to do a tomato, and I want to change the permissions, all the files all together instead of doing them one by one. They can get timing kind of TVs, especially in have. If you have a directory
with 50 or 60 files in it, you don't wanna go one by one and do it, you mod and change change the permissions on all those. So what you can do is you can actually just change
the permissions on every file inside the directory by going at the directory level where the files exist. So I have to be in the scripts. But see, here's, um, at home cyber admin scripts
and I could do a clod.
Some some seven dash are
And what that does is it takes that Scripts directory and Dash R's recursive, which means it takes everything under the scripts directory and turns. It changed the commissions on 777 which is read right, execute every user on the system. Okay, so now let's do a
Let me go back into the script directory. I'm gonna go back to change directory to the scripts
unless they can see that they're all agree And the turn all green like that, almost as if they're excusable when they have full on
all permission said 777
So if I go to L S h L A,
you can see all my commands. One of them being a directory is now. Also, my directory is going to be
right. My directory is going to be have the same permissions that I gave him a sedative. Recursive. Okay, I changed the permissions on the scripts directory and everything underneath it with a dash capital R
switch for our argument for recursive
so powerful things you can do with the command line when it comes to directors and fouls. So now we have it, We know how to make a directory, we know how to remove a directory. And I changed the permissions of a directory and file commissions.
Then the next thing to do
is to actually go ahead and get into file editing, which we're gonna get into in the next section.
So hope you enjoyed that tutorial on the file editing. It's really good stuff. If you get good at this, you could get really fast. And it's a very carful tool have. Like I said again. So dig in, get your Like I said, if you haven't had it up yet get your own destro up and start playing around this stuff. Get hands on experience.
Thanks for watching. And, uh, stay tuned for the next one.