When you use the mv
command you're just changing metadata about the top level directory or individual file, when you're using the cp
command you're literally making copies of a individual file or a directory tree. In order to differentiate between these two modes, the cp
command needs you to specify which behavior you want to enlist.
You can view the metadata using stat
.
$ stat /home/vagrant/adir
File: ‘/home/vagrant/adir’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd00h/64768d Inode: 794269 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-07-14 10:57:17.103849041 -0400
Modify: 2018-07-14 10:57:17.103849041 -0400
Change: 2018-07-14 10:57:17.103849041 -0400
Birth: -
After we move it:
$ stat /tmp/adir
File: ‘/tmp/adir’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd00h/64768d Inode: 794269 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-07-14 10:57:17.103849041 -0400
Modify: 2018-07-14 10:57:17.103849041 -0400
Change: 2018-07-14 10:57:53.323950044 -0400
Birth: -
The mv
command is just manipulating the metadata regarding the directory, and so doesn't need to actually make copies of anything to do this work.