files
mv
Moves or renames files and directories. Within a filesystem it just relinks; across filesystems it copies then deletes.
mv [OPTION]... SOURCE... DEST Common flags
| Flag | Purpose |
|---|---|
| -i | Prompt before overwriting DEST |
| -n | Never overwrite an existing file |
| -f | Force overwrite without prompting |
| -u | Move only if SOURCE is newer or DEST is missing |
| -v | Print each move as it happens |
Examples
mv old.txt new.txt Rename a file in place
mv *.log /var/log/archive/ Relocate matching files into a directory
mv -i draft.md posts/ Move safely, prompting on any conflict
mv -n build/ release/ Move without ever overwriting existing entries
Gotcha
There is no built-in undo; renaming over an existing file with -f discards it silently.
Related commands
cp
Copies files and directories from one location to another. Preserves or transforms metadata depending on flags.
rm
Removes files and, with -r, directory trees. Deletions are immediate and not recoverable from the shell.
ln
Creates hard or symbolic links between files. Symbolic links point to a path; hard links share the same inode.
ls
Lists directory contents including files and subdirectories. Supports detailed views, sorting, and filtering to inspect the filesystem quickly.
mkdir
Creates one or more directories. Can create nested paths and set the mode of new directories in a single call.