Skip to content

Using mv in Linux Commands

Published: at 12:00 AMSuggest Changes

Table of Contents

Open Table of Contents

Introduction

The mv command is used to move or rename files and directories in Linux. It is a fundamental command for file management.

Basic Usage of mv

Syntax

The basic syntax of mv is:

mv [options] source destination

Example

To move a file to a different directory:

mv file.txt /path/to/destination/

Advanced mv Techniques

Renaming Files

You can rename a file by specifying a new name in the destination.

Overwriting Files

By default, mv will overwrite files without prompting. Use the -i option to be prompted before overwriting.

Conclusion

Understanding the mv command is essential for effective file management in Linux.


Previous Post
Creating Directories with mkdir in Linux
Next Post
Using nano in Linux Commands