I cannot delete, copy, rename or move a file, all of these operations are the same or they're related
pretty much perform the same function.
So that is why I'm putting all of them in one lecture and I will cover all of them in this lecture one
by one.
So let's look at why there is always issue when we are trying to delete a file, copy, rename or move
a file, by the way, renaming or moving a file.
And then we use the same command, which is move.
So it doesn't matter what what we are renaming it to.
All in all, it matters if we are using the right syntax.
So let's go over our sequence that we already covered.
I'm going to go over really quickly and then I will log to our Linux machine.
I will try a few things that we think could impact these type of issues.
File does not exist.
As you know, we talked about it many times.
People make mistakes and file does not exist absolu pad versus the pad.
When you try to delete a file, make sure you are in a right directory and that file exists there.
If it's not the right directory, you're picking the right absolute path, then the file type.
If you are trying to delete a directory and you are using the R command, it will not delete it.
It will give you an error message or it will tell you that the file is a directory.
So you could either use RMI minus R Command or R MDI or command for a directory permissions.
One of the biggest thing, because I covered it so many times again, pen permission var talked above.
We have a user's itself who created it.
We have group and others.
Parent directory permissions should also comply with the rules.
If the parent directory does not allow you to to have the right permission and then you cannot delete
or move or any copy anything from that file, then we have hidden files.
Make sure the file is not hidden.
The command syntax is as important, uh, as any any of the above listed here.
So when you are typing or when you're deleting a file, it's simple that you remove followed by the
the name of the file.
But when you are copying it, it is important that the source comes in first because that's what you're
copying and the target comes later because that's where it is going to.
So that's pretty much the code we will cover.
Again, this is really quick.
I really want you to follow this and all of these steps one by one.
Now I'm going to log into our Linux machine and then we'll try a few of these things one by one.
So I am logged in as myself.
If I do so, not who.
If I do, who am I?
You'll see.
Sorry, I'm not logged in as myself.
I'm logged in as route.
As you notice, that route has a prompt of pound or hash.
I let me clear the screen now.
I will go into CD oi log and I will do X minus L tr and you will notice it has a bunch of files now.
Um, I wanted to delete this file bar log messages and you notice this file is owned by route and the
group of this file is route and it is allowed to be deleted or written by the owner itself.
So I am not going to delete it as my self, which is the route I will go ahead and duplicate the session,
meaning I will create another session to that to that server and I will log in as myself.
Now I'm logged in as myself and I do who I am, I will see I am logged in as I have, so I will go into
Kadivar log directory and I will go in and see the messages file.
And now this time I'm going to try to deleted our messages and hit enter.
And it is telling me remove right.
Protected a regular file messages.
Now it is asking you, do you really want to remove it?
When you say why it says permission denied.
Why it's his permission denied.
Because who am I.
I am I afsal ok.
Am I the group of this file.
No.
Am I the user of this file.
No.
OK, that is fine.
We confirm that now the user of this file has a read and write permissions, meaning only route which
is right here, has a read and write permission everybody else, which is the group or everyone else.
The others do not have any type of permission to either delete it, removed, copy, remove it or anywhere.
So if I am also trying to let's say the next step that I'm trying to do is copy this file if I want
to copy this messages file and I'll just copy messages.
And I wanted to copy it in my home directory, in my home directory home.
I have salt, it says cannot open messages for reading because the permission denied again.
Why?
Because I, I fall in this category right here in the last bit and in the last bit is telling me that
I do not have read permission.
If I had read permission I would be able to copy it.
So let's say if I assign the read permission to this file as root so I'll do change mod other plus uh
read because all you need is read permission to copy a file and then do messages.
Now when I do this myself tr you'll see only ah.
Which is to read the file is assigned to everyone else.
So if I do the same thing now copy messages to homosocial it did copy and when I go to home I absol
and do this myself.
TR you notice now it created a copy and now the copy of the file is owned by myself and my group and
it is actually it has actually transferred the same type of permissions that I had or the route had
being the owner of the route.
So that's what it's all about.
I cannot copy, cannot delete.
Now what if I have a directory, let's say temp.
So before I go to temp I'll slash.
I do.
Ls minus l tr and you notice the temp directory right here has.
All the permission that you could think of so I could actually copy the messages, file logged messages
into that directory as well, and let me copy.
Now, what if I create a directory and it does not have the right permission?
So if I try to copy that same file in Etsy, now you see Etsy right here.
This is the one Etsy is saying the group and anybody else do not have the right permission.
So even though I have given the Reid permission of messages, I can not copy that message messages file
an Etsy because now the source has a permission, but the destination doesn't have a permissions.
So keep that in mind.
It is very important that the source and the destination both should have the proper permissions.
So if I do, if I had enter, you could see it says cannot create regular file Etsy messages because
permission denied.
So keep these things in mind.
It is very important that the source permissions and the target permission should also be the same.
Now let's go to my home directory, which is home.
I have sold.
I have Absol.
I have a directory in this my home directory called Seidenfeld and when I do X minus L tr the sign file
directory if I do P wd again home I have sold Seinfeld.
The Seinfeld directory has these list of files and directories of one directory which is called Seinfeld
Family, and the other is Elaine, George, Kramer, David and Susan.
I will go ahead and focus on the files.
Susan, if you notice the files, Susan has the read and write permission for its own self, which is
me read and write for the group, which is also my group and the read permission for everyone else.
So if I wanted to delete this file, do you think that I should be able to delete it without any issue?
Let's try it.
R.M. Susan and hit enter.
Permission denied.
Oh my God.
Now what happened?
Why?
I'm not able to delete this file now at this point, when you look at it, first thing you have to make
sure is you have the correct permission to file me.
The file is owned by me and myself.
It's right here.
Yes.
And who am I?
I am myself.
OK, so that is that has been confirmed.
That file is owned by me.
Who's the group?
I'm the group as well.
And for me I do have the right permission.
I do have this group as written by permission.
Then why can I deleted.
Now I want you to think in a broader way.
Go one step back and find out if the directory where this file is located, which is Zionsville, if
this directory allows you to delete the files or not.
Let's go back.
Qty, dot, dot, dot.
This is to go one step back.
Do you see I'm one step back now.
I will do a myself tr and file the direct read that Susan File was and is Seidenfeld and look at that
right here myself, which is I have solved this.
The first three bits are for me.
I do not have the right permissions.
That is why it did not allow me to delete the file.
So again, it is very important that you also check the parent directory and make sure the parent directory
is has or has the correct permissions.
Also make sure it is owned by the right person.
So let's say if I create a file in this directory in my Seidenfeld home, so as as root, so I log in,
I will come into home, I absol because I'm route on this window and I could go anywhere and inside
I felt sorry in here I will create a directory and I will call it make.
Dyax route.
They are one, so now they're rude, dear one has this directly, it is owned by Root, it is owned
by route group.
Root itself has read right executable.
Everybody else can log it can get into the directory.
Everybody else in the group can get into the area, but they cannot delete anything.
So I'm going to go into route directly and I'm going to create a file.
ABC, the ABC File is created and everybody.
And if you notice the permission of the ABC file, it only has its own self read and write to everybody
else has read.
So now I am logged in as myself and the other window.
Who am I?
I have.
So now you notice that this one has a directory called Root Directory and this is the file ABC remove
ABC.
Yes.
And it says permission denied.
So it did not allow me to delete it.
OK, so now how about I change the permission for it to be deleted.
So ABC is the file so I will like to have change eh.
All of them.
Plus write ABC.
Now everybody has permission, perfect.
Now you come in here and try to delete it and it's his permission denied.
Why is that?
Why I cannot delete it now.
I just gave it the right permission.
Right.
So let's go back one step and let's verify the root directory self directory.
It says, look at that.
There is no right permission to anybody.
So these are the things I am telling you this the second time.
So make sure you need to check your parent directory.
Let's talk about the next thing I want to talk about is the renaming of the file.
So if I am logged in as myself.
Sorry, who am I?
And I will go into the Seinfeld directory.
And I wanted to rename.
Susan, so I'll do move Susan to Susan one.
I could still I still cannot do it.
Why?
Because I do not have the right permission.
Perfect.
So I'll go one step back and I will allow the right permission to the directory.
So change my God.
A by the way, at this time I'm going to pick minus or minus or will Kaskade the permissions down to
any sub folders as well.
So all should have a plus W.
Zionsville now if I do, Saiful.
You see, everybody has the permission to do anything in the Seinfeld directory.
Now, if I go and to the Seinfeld directory and who else myself, tr now if I try to move to Susan,
to Susan one, I should be able to.
That's one thing.
Second thing is if you want to rename and you do not give the destination name.
So let's say if I want to move Susan one you wanted to give it a destination name.
Right.
If you don't give it, it will tell you missing destination for and after Susan won.
So it's basically telling you, in other words, that you have to specify the right name for Susan.
So the right name that I'm putting to rename it up.
Put Susan, too.
And the Susan to file has been changed.
So that's about moving the file or renaming the file.
So you rename the file if you want to move from one location to another.
We talked about it as well.
But if you do not specify the destination location, it will give you a message.
Last thing I will cover is if you notice that right now, if I go one step back right now, Seinfeld
has all the permissions that it could think of in the world.
So if I wanted to go into this, I directly and delete it, delete something, is it going to allow
me to delete it?
Well, it depends on the parent directory that is sitting on top of Seinfeld directory.
If I do dot, dot and explain Selter, you notice no one has any type of permission to come to my directory,
which is Afsal, and do anything in there.
They cannot even come in and actually go into the directory or CD into that area.
So here are a few things that I covered.
Hopefully this lecture served its purpose.
If you have any question and if you are still having any issues with deleting, copying or renaming
or moving a file, please send me a message and I will create a new lecture for you to go over and troubleshoot
that issue with you.