mv

file managementLinux/Unix
The mv command is one of the most frequently used commands in Linux/Unix-like operating systems. mv Sample fallback description for mv

Quick Reference

Command Name:

mv

Category:

file management

Platform:

Linux/Unix

Basic Usage:

mv old_name.txt new_name.txt

Common Use Cases

  • 1

    File moving

    Move or rename files and directories

  • 2

    File organization

    Organize files and directories hierarchically

  • 3

    Data migration

    Move files between systems or locations

  • 4

    Scripting

    Use in shell scripts to automate file moving

Syntax

mv [OPTION]... [FILE]...

Options

Option Description
-l Use a long listing format
-a Show hidden entries starting with .
-h Human-readable sizes
-R List subdirectories recursively

Examples

How to Use These Examples

The examples below show common ways to use the mv command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

ls
List files in the current directory.
ls -l
List files in long format with details.
ls -a
List all files including hidden ones.

Advanced Examples:

ls -lah Detailed list with human-readable sizes. ls -R List directories recursively.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

These are sample notes for the mv command.

Tips & Tricks

1

Use the -i option to prompt before overwriting

2

Use the -f option to force overwrite

3

Use the -n option to not overwrite existing files

4

Use the -b option to preserve the destination file's backup

5

Use the -u option to move only if the source file is newer

Common Use Cases

File moving

Move or rename files and directories

File organization

Organize files and directories hierarchically

Data migration

Move files between systems or locations

Scripting

Use in shell scripts to automate file moving

File management

Manage files and directories in the filesystem

Related Commands

These commands are frequently used alongside mv or serve similar purposes:

Use Cases

1

File moving

Move or rename files and directories

2

File organization

Organize files and directories hierarchically

3

Data migration

Move files between systems or locations

4

Scripting

Use in shell scripts to automate file moving

5

File management

Manage files and directories in the filesystem

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the mv command works in different scenarios.

$ mv
View All Commands