I know in Linux, if we want to rename a folder from f_old
to f_new
, we can run:
mv f_old f_new
But this command actually confuses me. Does the system copy all stuff inside f_old
, paste it to new folder f_new
and delete f_old
at last? Or does it just rename f_old
to f_new
?
The mv command moves files and directories from one directory to another or renames a file or directory. If you move a file or directory to a new directory, it retains the base file name. When you move a file, all links to other files remain intact, except when you move it to a different file system.
Moving Files To move files, use the mv command (man mv), which is similar to the cp command, except that with mv the file is physically moved from one place to another, instead of being duplicated, as with cp.
Use the mv command to move files and directories from one directory to another or to rename a file or directory. If you move a file or directory to a new directory without specifying a new name, it retains its original name.
mv is a Unix command that moves one or more files or directories from one place to another. If both filenames are on the same filesystem, this results in a simple file rename; otherwise the file content is copied to the new location and the old file is removed.
As long as the target location is on the same partition (filesystem) as the source, no data will get moved or even touched. Only the name in the directory entry gets changed.
If the target is on a separate partition, the data will first get copied to the target and then removed from source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With