mv (short for move) 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. Using mv requires the user to have write permission for the directories the file will move between. This is because mv changes the content of both directories (i.e., the source and the target) involved in the move. When using the mv command on files located on the same filesystem, the file's timestamp is not updated.
On UNIX implementations derived from AT&T UNIX, cp, ln and mv are implemented as a single program with hard-linked binaries. The behavior is selected from the last path component name in argv[0]. This is a common technique by which closely related commands that have been packaged as a unit allow the user to specify the particular course of intended action.
When a filename is moved to an existing filename, the existing file is deleted. If the existing file is not writable but is in a directory that is writable, the mv command asks for confirmation (if run from a terminal) before proceeding, unless the -f (force) option is used
Moving files within the same file system is generally implemented differently than copying the file and then removing the original. On platforms that do not support the rename syscall, a new link is added to the new directory and the original one is deleted. The data of file is not accessed. All POSIX-conformant systems implement the rename call.
An actual move (viz., a rename) is dramatically faster than the circuitous copy-and-move procedure. The file's i-number (short for "i-node number") does not change. No permission is required to read the file being moved insofar as—conceptually speaking—it is only cataloguing information that is being changed as a result of the "move." Since the source and target directories are being modified, to wit, entries are being created within the target directory and erased from within the source directory, "write" permission in both directories is required to complete the move. Moving files from one file system to another may fail entirely or may be automatically performed as a unific copy-and-delete action; the actual details are dependent upon the implementation.
Write permission on the directory being migrated (so to speak) is additionally required in the case where a directory is being re-parented, sciz., moved to a different parent directory. This is because the ".." entry—which can always be used as an "alias" for its parent if you don't know the parent's name—must be changed within the migrant per se.