Linux Copy, Move & Rename Files
4K views
Nov 28, 2024
Linux Copy, Move & Rename Files
View Video Transcript
0:00
so into our previous video already we
0:02
have seen how we can create a fur so let
0:05
us begin well if I want to copy move or
0:08
rename of what the commands would be
0:10
using here so if I want to copy a file
0:14
we have a CP command
0:15
same way if I want to remove or rename a
0:18
file we have a MV command so MV
0:21
basically is a move command where we can
0:23
locate a directory or a file created on
0:26
one location to any particular location
0:28
so basic basically it is cut and paste
0:31
you are cutting from original location
0:34
and you're pasting it into a different
0:36
location that is a move same way this
0:39
particular command can also be used for
0:41
renaming of a so basically concept which
0:45
generally it follows is it cuts a file
0:47
from the same location and paste the
0:50
file into the same location with a
0:52
different name so generally it is again
0:54
used for renaming of well the next
0:57
command we have that is CP CP is for
0:59
copying of so you can copy a file in the
1:02
same location with a different name or
1:04
you can copy a file into the different
1:06
location as well the difference between
1:08
move and copy is Mobile delete the file
1:11
from the origin location and it will be
1:13
completely transferred to the other
1:14
location while the copy will keep the
1:17
data in both the location the original
1:19
as well as the destination location
1:21
which we generally use into the Windows
1:23
operating system as well let us check
1:25
into the terminal
1:26
how we use this commands so here on the
1:29
suite you we are going to see how to
1:31
rename a file first so into our earlier
1:33
video we have created file1 and file2
1:36
for example i want to rename this file
1:39
file1 so if i want to rename the file i
1:42
can give the command MV so as we have
1:45
already discussed earlier we can use mp4
1:47
in naming the file as well as we can use
1:50
the same command for moving a file as
1:53
well first I am going to rename it I
1:55
want to rename a file with name file 1
1:58
to a new file name for example I am
2:01
going to define the file name as dock 1
2:03
and hit enter
2:04
QT come on less long can find file 1 is
2:09
not there and we got the command or
2:12
default with name doc one let's check
2:17
the doc one so doc one you can check the
2:21
content of the doc one by giving the
2:23
command cat doc one can see we have at
2:32
the same line here the cat file come on
2:34
is to add in the file system
2:37
simultaneously so this was the content
2:40
of the doc one same what we had into the
2:42
file one right so here what we did is we
2:45
move the data from or the file one from
2:48
the same location and we have just
2:50
copied it on the same location that's
2:52
what exactly the moving does so for
2:55
example now I want to move this doc one
2:59
from my home directory to the desktop so
3:06
if I want to do that I can give the same
3:09
command MV for moving a file which while
3:13
I want to move us doc one now where I
3:15
want to move I want to move into home
3:18
who stick stopped my trainers tech stop
3:21
so trainer slash desktop index top D
3:26
should be capital hit enter and I can
3:30
see it graphically also we can see your
3:33
doc one is moved here now if I give the
3:35
command ll there is no doc one that
3:38
means I have moved the file from my home
3:40
directory to the desktop same way if I
3:43
want to move back again I can give the
3:45
command MV where I have located the doc
3:50
one the source complete path I have net
3:52
redefine home slash trainer slash
3:58
desktop slash the document file name doc
4:04
one and where I want to move it for
4:07
moving it here itself just I'll give the
4:09
dot okay so the next op spelling is
4:13
wrong I need to add right so you can
4:20
check from there we cannot find doc one
4:23
now it is moved back to your
4:25
location so defying a same location you
4:27
can also define dot now same way if I
4:32
want to move all files from here to any
4:38
particular location I can also define by
4:40
giving dot to the other location all of
4:44
I want to define any particular file
4:47
which is starting with D I want to move
4:50
it to any other location like for
4:52
example I want to move it to slash home
4:54
slash trainer slash documents so we also
5:00
have the document directory into the
5:02
trainer let us check it does is it does
5:08
not have here now this D file there's a
5:12
file which you're starting with D was
5:13
your only doc one so we have moved into
5:16
the document so if I want to move inside
5:19
the document directory I can give the
5:21
command CD space document and hit enter
5:28
you can see doc one is located over here
5:31
this means how you can move a file from
5:34
one location to another location or if
5:37
you can rename a file by using the MV
5:39
command itself now here I'm going to
5:41
show you the another command which we
5:43
are going to discuss here that is your
5:45
copy so into our previous video we have
5:48
seen we have already moved a file from
5:52
the other location to this location
5:54
right now this is I am into the
5:56
documents wiggins check the PWD command
6:01
I am in the document I am in - slash
6:03
home slash trainer and slash documents
6:05
means I'm in a documents of the trainer
6:07
user now I want to copy this doc one in
6:12
the same place with a different name I
6:14
can do it how we'll be doing it by
6:17
giving the command CP doc 1 and I want
6:23
to save this file over here itself with
6:26
a different name for example we can add
6:28
with demo 1 hit enter let us check we
6:33
got both defaults then one under doc
6:36
want
6:38
now if I want to copy the same file on
6:41
my desktop I'll be giving the command
6:44
home slash trainer or if suppose I want
6:50
to define the same file here I can also
6:53
define the name of the file like demo
6:55
one I want to copy to slash home slash
6:59
trainer slash desktop and if I give you
7:09
ten - it will copy the file with the
7:11
same name demo one now if I want to copy
7:16
the file the same file demo1 with a
7:19
different name what I'll do I'll just
7:21
give the name of the file which I want
7:24
to keep it over there so I'll just
7:27
define the file name as data one so it
7:30
is a copy of demo one with the name data
7:32
one let us check the content of demo one
7:35
or your existing original file demo1
7:39
this is the content even here if I click
7:42
and - demo one I'll get the same content
7:45
into it right same way even here I will
7:50
get the same content got it
7:53
that means we have treated a copy of
7:55
this document into multiple places so
7:58
this is we have seen how we can use MV
8:00
command for renaming a file MV command
8:03
for moving a file as well as MV command
8:05
we have used for replacing a file or to
8:09
change the location of a file same here
8:12
we have seen copy command we have copied
8:14
the file into the same location as well
8:16
as into a different location with the
8:18
same name as well as into a different
8:20
name so in the next video I am coming up
8:23
with more file management
#Operating Systems
#Programming
#Software