How to Move a File from One Directory to Another in Linux?
Contents

Moving files with mv.

To move a file or directory from one location to another, use the command mv.

Common useful options for mv include: -i (interactive) — Prompts you if the file you have selected overwrites an existing file in the destination directory.

How do you move a file to another directory in Linux?

mv command is used to move files and directories.

  • mv command syntax. $ mv [options] source dest.
  • mv command options. mv command main options: option. description.
  • mv command examples. Move main.c def.h files to /home/usr/rapid/ directory: $ mv main.c def.h /home/usr/rapid/
  • See also. cd command. cp command.

How do I move a file from one directory to another in Unix?

To move a file into a directory using the mv command pass the name of the file and then the directory. In the following example the file foo.txt is moved into the directory bar .

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest