Hi everybody and welcome to part two of the next command line mini module.
In this video we're going to be talking about working with files and folders or files and directories.
Now there are gonna be some overlaps between Windows and Linux.
However when it comes to manipulating the files and folders it is entirely different on a Linux platform
than it is Windows.
So the first we want to take a look at it let's make a directory.
So it's it's very similar to windows make the are right.
So we're going to do a test one is our directory.
Now in windows we would do DVR which in this case Linux does have a desire but that wasn't always the
case in Linux.
What you're going to want to do is something called Alice.
So this will list the current directory.
What I like to do is do a dash L at the end.
So if we look at just LSA It just dumps it into one file and just for shits and giggles we'll do we'll
make two directories the new Alice.
You can see it just dumps them to next to each other.
Right.
So if we do Alice dash l it tells us the permissions which is that first bit right.
We're gonna go over on all of this so that we have the user group and then we've got the date that it
was last modified and we've got weather in this for example the D at the beginning it shows us it's
a fort.
It's a directory.
So go ahead and remove the directory which will go over in a second.
So also in Windows it's CFS and Windows it's I'm sorry Windows it's clear.
And then when one exit CNS backwards.
So I see a lesson windows clear in Linux.
Now let's dash out now we've got our test directory one so we'll go ahead and see into that directory
and we can see there's no files so there's a few ways we can create files and there's probably 100 different
ways to create a file in any platform.
However we're going to go over the two standard ones we have Echo which is similar that what we used
before.
Right.
So type this into a secret.
Now what's important here is Linux doesn't necessarily care about file extensions.
It doesn't really care about them at all.
Now in Windows platforms they do that t t is much different than a dot e XY and it will be handled differently
based on what the registry entries around what objects should be identified and how.
Now with Linux you.
It identifies it based on what's in the file not what the extension is.
So just keep that in the back of your mind.
So we take a look we see our secret and Google over cat later but had essentially just prints out whatever
Texas in the file it is similar to the word type and windows.
So if we cat out secret we see we've got our text now believe its files secret.
Yeah.
So file secret so file is a quick command.
I'm not going to go over that in this video but file will just allow you to check what type of file
it is so in this case it's an ASCII text it's standard text file.
So we've got our secret.
Now let's say we want to rename it.
So there's no rename persay.
So you really have to do is move it to move a file.
It's the secret number going to call it secret to write now if we go in and look in here we now see
we have a secret too.
So if we want to revert that and we'll bring it back to our secret one we do that.
Now I've got it secret again.
Again it's still the same file.
So what happens if we want to copy the file.
So we would do copy secret git instead of doing the forward copy it's just sleepy and then we'll do
secret to that shows we have to if we kept a secret to we had our right to nation perfect.
Now what's another way to create a file.
You could do something called Touch which basically just creates an empty file or it will or will overwrite
the current file with nothing.
So if we did secret three we now have secret three.
But if we kept secret three there's not even a new line it's completely blank.
Absolute Zero.
Nothing in it.
Now we've got our three files in our directory.
So if we go back a directory and we have our test one.
Now let's say we wanted to copy our entire directory over.
Now in Windows you'd have to create a file and then copy the contents over in Linux we can copy the
whole directory.
So we use copy Dash are for recursive ness so grab everything in the file in the folder that we're going
to copy.
Test one two test two.
Now we do that we go ahead and see and to test to we see the same the same files.
Right.
Perfect.
Now let's say we've made a mistake.
We want to get rid of test too.
How do we delete it now.
DL is not present in Linux.
So what you have is all right which is remove file.
Now remember what I said before is everything on Linux as a file.
The folder is technically a file.
So what we want to do is we want to remove the files recursively for test two.
Now the dash allows for recursive.
Now if you don't put Dash are it will not let you delete the directory so you need to have the recursive.
Now if it's a single file we can do our and then the file name.
But we are going to see here is when we do this.
We get nothing.
Perfect.
Call test tube is now gone.
Now what we're going to want to do is look at removing a file so we're going to test one let's say you
want to remove secret.
Now what happens if we want to move everything in this particular directory.
We could do our own star.
Now when you do this make sure you are not in a directory you plan on caring about because there's no
like you should be there's no indication that something is about to get deleted.
It just deletes it.
So right now this is empty.
There's no there's no there's no undo.
There's no like trash bin from the command line per say.
Now there are like forensic ways to bring back stuff playing with bits and bytes but we're definitely
not gonna be going over that in this particular course.
So understanding how to move the directories is how to create how to create the files.
Touch is going to be a big best friend of yours.
That goal is gonna be relatively the same.
Moving stuff.
Was it just the removing stuff as ah and making sure we are moving things in the correct way.
Another key part is r n dash R F which means if you run into the problem where you're doing an arm dash
R and a folder right and you start getting it saying Are you sure you want to delete this you had to
click y.
Are you sure you want to delete this.
You have to click y and you have to do that for every file.
So what this does is the R F means force it force it to be deleted.
So if you do that it will not prompt you.
Everything is gone.
In this particular case it didn't need to but if it finds that there's something weird about the file
that you shouldn't probably delete it.
Or maybe you're deleting too many and it just double checking.
It'll start asking you for each file.
So the F part just makes it completely removable.
Now if you did this very bad.
Don't do it.
That will wipe out everything in the root drive.
So think of that as C which is not good.
That's all your system files everything else like that.
So there are some malware that just as soon as they get on the machine they just do this.
That's it got whole system gone.
So play around with it get familiar with the command line and creating files moving things around deleting
files get familiar with it.
It's it's a very core concept on the lakes platform and in most cases when you're on an engagement you'll
probably be using something like Kelly Linux which is a Linux platform.
And when you gain access to an enterprise system most likely it's a Linux platform.
So player it get used to it.
If you have any questions feel free to swing over to the Facebook group.