move and copy

Posted on 2013-02-03
Last Modified: 2013-02-06
what is the difference between mv command and cp command in linux
Question by:walkerdba
LVL 30

Expert Comment

ID: 38848542

mv just update a pointer in the filesystem whereas cp does that and copy so mv is faster

Expert Comment

ID: 38848566
The one comand moves the file, delete it, and copy to new location. Cp -copyes the file and the source of the file states on  it's plays.
LVL 68

Expert Comment

ID: 38848576
mv across a filesystem boundary means copying (possibly under a new name)  then deleting the source file, cp is always just a copy (possibly under a new name) without any deletion.

mv inside a filesystem just updates the directory inode(s) with the new file location (and possibly a new name) and doesn't displace any data.

mv inside a directory is always just a rename operation.
LVL 40

Accepted Solution

omarfarid earned 500 total points
ID: 38848811
cp will always copy file to another

mv could mean:

move file from one place to another (same dir or different dir or filesystem)

rename file

Author Closing Comment

ID: 38860548

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question