{
    "mode": "info",
    "parameter": "mv",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/mv/json",
    "generated": "2026-11-15T15:49:01Z",
    "sections": {
        "File: coreutils.info,  Node: mv invocation,  Next: rm invocation,  Prev: install invocation,  Up: Basic operations": {
            "content": "",
            "subsections": [
                {
                    "name": "11.4 'mv': Move (rename) files",
                    "content": "'mv' moves or renames files (or directories).  Synopses:\n\nmv [OPTION]... [-T] SOURCE DEST\nmv [OPTION]... SOURCE... DIRECTORY\nmv [OPTION]... -t DIRECTORY SOURCE...\n\n* If two file names are given, 'mv' moves the first file to the\nsecond.\n\n* If the '--target-directory' ('-t') option is given, or failing that\nif the last file is a directory and the '--no-target-directory'\n('-T') option is not given, 'mv' moves each SOURCE file to the\nspecified directory, using the SOURCEs' names.\n\nTo move a file, 'mv' ordinarily simply renames it.  However, if\nrenaming does not work because the destination's file system differs,\n'mv' falls back on copying as if by 'cp -a', then (assuming the copy\nsucceeded) it removes the original.  If the copy fails, then 'mv'\nremoves any partially created copy in the destination.  If you were to\ncopy three directories from one file system to another and the copy of\nthe first directory succeeded, but the second didn't, the first would be\nleft on the destination file system and the second and third would be\nleft on the original file system.\n\n'mv' always tries to copy extended attributes (xattr), which may\ninclude SELinux context, ACLs or Capabilities.  Upon failure all but\n'Operation not supported' warnings are output.\n\nIf a destination file exists but is normally unwritable, standard\ninput is a terminal, and the '-f' or '--force' option is not given, 'mv'\nprompts the user for whether to replace the file.  (You might own the\nfile, or have write permission on its directory.)  If the response is\nnot affirmative, the file is skipped.\n\nWarning: Avoid specifying a source name with a trailing slash, when\nit might be a symlink to a directory.  Otherwise, 'mv' may do something\nvery surprising, since its behavior depends on the underlying rename\nsystem call.  On a system with a modern Linux-based kernel, it fails\nwith 'errno=ENOTDIR'.  However, on other systems (at least FreeBSD 6.1\nand Solaris 10) it silently renames not the symlink but rather the\ndirectory referenced by the symlink.  *Note Trailing slashes::.\n\nNote: 'mv' will only replace empty directories in the destination.\nConflicting populated directories are skipped with a diagnostic.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-b'\n'--backup[=METHOD]'\n*Note Backup options::.  Make a backup of each file that would\notherwise be overwritten or removed.\n\n'--debug'\nPrint extra information to stdout, explaining how files are copied.\nThis option implies the '--verbose' option.\n\n'-f'\n'--force'\nDo not prompt the user before removing a destination file.  If you\nspecify more than one of the '-i', '-f', '-n' options, only the\nfinal one takes effect.\n\n'-i'\n'--interactive'\nPrompt whether to overwrite each existing destination file,\nregardless of its permissions, and fail if the response is not\naffirmative.  If you specify more than one of the '-i', '-f', '-n'\noptions, only the final one takes effect.\n\n'-n'\n'--no-clobber'\nDo not overwrite an existing file; silently fail instead.  If you\nspecify more than one of the '-i', '-f', '-n' options, only the\nfinal one takes effect.  This option is mutually exclusive with\n'-b' or '--backup' option.  See also the '--update=none' option\nwhich will skip existing files but not fail.\n\n'--no-copy'\nIf a file cannot be renamed because the destination file system\ndiffers, fail with a diagnostic instead of copying and then\nremoving the file.\n\n'-u'\n'--update'\nDo not move a non-directory that has an existing destination with\nthe same or newer modification timestamp; instead, silently skip\nthe file without failing.  If the move is across file system\nboundaries, the comparison is to the source timestamp truncated to\nthe resolutions of the destination file system and of the system\ncalls used to update timestamps; this avoids duplicate work if\nseveral 'mv -u' commands are executed with the same source and\ndestination.  This option is ignored if the '-n' or '--no-clobber'\noption is also specified.\n\nWHICH gives more control over which existing files in the\ndestination are replaced, and its value can be one of the\nfollowing:\n\n'all'\nThis is the default operation when an '--update' option is not\nspecified, and results in all existing files in the\ndestination being replaced.\n\n'none'\nThis is similar to the '--no-clobber' option, in that no files\nin the destination are replaced, but also skipping a file does\nnot induce a failure.\n\n'older'\nThis is the default operation when '--update' is specified,\nand results in files being replaced if they're older than the\ncorresponding source file.\n\n'-v'\n'--verbose'\nPrint the name of each file before moving it.\n\n'--strip-trailing-slashes'\nRemove any trailing slashes from each SOURCE argument.  *Note\nTrailing slashes::.\n\n'-S SUFFIX'\n'--suffix=SUFFIX'\nAppend SUFFIX to each backup file made with '-b'.  *Note Backup\noptions::.\n\n'-t DIRECTORY'\n'--target-directory=DIRECTORY'\nSpecify the destination DIRECTORY.  *Note Target directory::.\n\n'-T'\n'--no-target-directory'\nDo not treat the last operand specially when it is a directory or a\nsymbolic link to a directory.  *Note Target directory::.\n\n'-Z'\n'--context'\nThis option functions similarly to the 'restorecon' command, by\nadjusting the SELinux security context according to the system\ndefault type for destination files and each created directory.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}